-
Notifications
You must be signed in to change notification settings - Fork 20
feat: support 'same-as-agent' model option for legacy evaluators #1048
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
48a0c5e to
9e71de8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it's better to do something like this:
from typing import Protocol, runtime_checkable
@runtime_checkable
class LLMAgentProtocol(Protocol):
def get_agent_model(self) -> str:
...
And switch the implementation of _get_agent_model to:
def _get_agent_model(self, runtime: UiPathRuntimeProtocol) -> str | None:
if isinstance(runtime, LLMAgentProtocol):
return runtime.get_agent_model()
else:
return None
That way, react agent can implement that method and it should work seamlessly.
Good catch implemented your Protocol-based pattern. |
|
I don't think the factory should contain the model. It's a runtime concept. I.e; the factory can create different runtimes with different LLMs based on the entrypoint, so I'd rather keep it in runtime. This is why Also, please create a unit test to test the change :) |
mathurk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Add support for the 'same-as-agent' model configuration in legacy LLM-based evaluators. When an evaluator specifies 'same-as-agent' as its model, it now resolves to the actual model from agent.json settings instead of throwing an error. Changes: - Updated EvaluatorFactory to accept and pass agent_model parameter - Added _get_agent_model() method to runtime to load model from agent.json - Added logging for model resolution and evaluator creation - Fixed error message in trajectory evaluator (was incorrectly saying "LLM evaluator") 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Implements the Protocol-based approach for getting agent model: - Adds LLMAgentFactoryProtocol with get_agent_model() method - Updates _get_agent_model() to check if factory implements protocol - Falls back to file-based approach if protocol not implemented This allows runtime factories to provide agent model information directly, enabling cleaner 'same-as-agent' resolution for evaluators. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Addresses PR review feedback: - Rename LLMAgentFactoryProtocol to LLMAgentRuntimeProtocol (it's a runtime concept) - Remove agent.json fallback logic (runtime handles this) - Make _get_agent_model() async - creates temp runtime to query model - Add _find_agent_model_in_runtime() for recursive delegate traversal - Make _load_evaluators() async to support async model query The runtime (AgentsLangGraphRuntime) now implements get_agent_model(), and wrapper runtimes (TelemetryRuntimeWrapper) delegate appropriately. This follows the principle that model info is a runtime property, not factory. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
6beb0e0 to
a3fde44
Compare
Combines schema and agent model fetching into a single _ensure_metadata_loaded() method that creates one temporary runtime instead of potentially two separate ones. Results are cached for subsequent access, improving performance when both schema and agent model are needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| if isinstance(runtime, LLMAgentRuntimeProtocol): | ||
| return runtime.get_agent_model() | ||
|
|
||
| # Check for delegate property (used by UiPathResumableRuntime, TelemetryRuntimeWrapper) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer adding this method in UiPathResumableRuntime and TelemetryRuntimeWrapper but we can do this later..
akshaylive
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to refactor the eval runtime to ensure one runtime instance per evaluation but that can happen in a separate PR.
Please add a unit test to ensure that get_agent_model logic doesn't break during the future refactor before merging.
Add comprehensive tests for: - LLMAgentRuntimeProtocol detection - _find_agent_model_in_runtime recursive delegate traversal - _ensure_metadata_loaded caching behavior - _get_agent_model cached retrieval - get_schema cached retrieval - Realistic wrapper chain model resolution 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
d7fa304 to
3b74169
Compare
akshaylive
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
same-as-agentmodel configuration in legacy LLM-based evaluatorssame-as-agentas its model, it now resolves to the actual model from the agent runtimeLLMAgentRuntimeProtocolfor runtimes to provide model informationChanges
LLMAgentRuntimeProtocol- protocol for runtimes that can provide agent model info_get_agent_model()to be async and query model from runtime (not factory)_find_agent_model_in_runtime()for recursive delegate traversal through runtime wrappers_load_evaluators()to be async to support async model queryArchitecture
The model resolution follows the runtime wrapper chain:
Companion PR
This PR works with uipath-agents-python PR that implements:
AgentsLangGraphRuntime.get_agent_model()- loads model from agent.jsonTelemetryRuntimeWrapper.get_agent_model()- delegates to underlying runtimeAgentsRuntimeFactory- removed get_agent_model (it's a runtime concept, not factory)Test plan
LLMAgentRuntimeProtocolintegrationcalculator_same_as_agentexample containing evaluators with"model": "same-as-agent"🤖 Generated with Claude Code