Skip to content

Commit 0e59c8f

Browse files
committed
fix: remove obsolete llm agent protocol from evals
1 parent bb02d33 commit 0e59c8f

2 files changed

Lines changed: 3 additions & 124 deletions

File tree

src/uipath/_cli/cli_eval.py

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from uipath.runtime import (
1111
UiPathRuntimeContext,
1212
UiPathRuntimeFactoryRegistry,
13-
UiPathRuntimeProtocol,
1413
UiPathRuntimeSchema,
1514
)
1615

@@ -19,7 +18,6 @@
1918
from uipath._cli._evals._models._evaluation_set import EvaluationSet
2019
from uipath._cli._evals._progress_reporter import StudioWebProgressReporter
2120
from uipath._cli._evals._runtime import (
22-
LLMAgentRuntimeProtocol,
2321
UiPathEvalContext,
2422
)
2523
from uipath._cli._evals._telemetry import EvalTelemetrySubscriber
@@ -70,34 +68,7 @@ def setup_reporting_prereq(no_report: bool) -> bool:
7068
return True
7169

7270

73-
def _find_agent_model_in_runtime(runtime: UiPathRuntimeProtocol) -> str | None:
74-
"""Recursively search for get_agent_model in runtime and its delegates.
75-
76-
Runtimes may be wrapped (e.g., ResumableRuntime wraps TelemetryWrapper
77-
which wraps the base runtime). This method traverses the wrapper chain
78-
to find a runtime that implements LLMAgentRuntimeProtocol.
79-
80-
Args:
81-
runtime: The runtime to check (may be a wrapper)
82-
83-
Returns:
84-
The model name if found, None otherwise.
85-
"""
86-
# Check if this runtime implements the protocol
87-
if isinstance(runtime, LLMAgentRuntimeProtocol):
88-
return runtime.get_agent_model()
89-
90-
# Check for delegate property (used by UiPathResumableRuntime, TelemetryRuntimeWrapper)
91-
delegate = getattr(runtime, "delegate", None) or getattr(runtime, "_delegate", None)
92-
if delegate is not None:
93-
return _find_agent_model_in_runtime(delegate)
94-
95-
return None
96-
97-
98-
async def _get_agent_model(
99-
runtime: UiPathRuntimeProtocol, schema: UiPathRuntimeSchema
100-
) -> str | None:
71+
async def _get_agent_model(schema: UiPathRuntimeSchema) -> str | None:
10172
"""Get agent model from the runtime schema metadata.
10273
10374
The model is read from schema.metadata["settings"]["model"] which is
@@ -113,12 +84,7 @@ async def _get_agent_model(
11384
if model:
11485
logger.debug(f"Got agent model from schema.metadata: {model}")
11586
return model
116-
117-
# Fallback to protocol-based approach for backwards compatibility
118-
model = _find_agent_model_in_runtime(runtime)
119-
if model:
120-
logger.debug(f"Got agent model from runtime protocol: {model}")
121-
return model
87+
return None
12288
except Exception:
12389
return None
12490

@@ -395,7 +361,7 @@ async def execute_eval():
395361
eval_context.evaluators = await EvalHelpers.load_evaluators(
396362
resolved_eval_set_path,
397363
eval_context.evaluation_set,
398-
await _get_agent_model(runtime, eval_context.runtime_schema),
364+
await _get_agent_model(eval_context.runtime_schema),
399365
)
400366

401367
# Runtime is not required anymore.

tests/cli/eval/test_eval_runtime_metadata.py

Lines changed: 0 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
- _ensure_metadata_loaded() - single runtime creation for both schema and agent model
55
- _get_agent_model() - cached agent model retrieval
66
- get_schema() - cached schema retrieval
7-
- _find_agent_model_in_runtime() - recursive delegate traversal
8-
- LLMAgentRuntimeProtocol - protocol implementation detection
97
"""
108

119
import uuid
@@ -31,7 +29,6 @@
3129
UiPathEvalRuntime,
3230
)
3331
from uipath._cli.cli_eval import (
34-
_find_agent_model_in_runtime,
3532
_get_agent_model,
3633
)
3734
from uipath._events._event_bus import EventBus
@@ -156,50 +153,6 @@ def test_protocol_rejects_wrapper_without_method(self):
156153
assert not isinstance(wrapper, LLMAgentRuntimeProtocol)
157154

158155

159-
class TestFindAgentModelInRuntime:
160-
"""Tests for _find_agent_model_in_runtime recursive search."""
161-
162-
def test_finds_model_in_direct_runtime(self):
163-
"""Test finding agent model directly on runtime."""
164-
runtime = AgentModelRuntime("gpt-4o")
165-
result = _find_agent_model_in_runtime(runtime)
166-
assert result == "gpt-4o"
167-
168-
def test_finds_model_in_wrapped_runtime(self):
169-
"""Test finding agent model through wrapper's delegate."""
170-
inner = AgentModelRuntime("claude-3")
171-
wrapper = WrapperRuntime(inner)
172-
result = _find_agent_model_in_runtime(wrapper)
173-
assert result == "claude-3"
174-
175-
def test_finds_model_in_deeply_wrapped_runtime(self):
176-
"""Test finding agent model through multiple wrapper layers."""
177-
inner = AgentModelRuntime("gpt-4-turbo")
178-
wrapper1 = WrapperRuntime(inner)
179-
wrapper2 = WrapperRuntime(wrapper1)
180-
result = _find_agent_model_in_runtime(wrapper2)
181-
assert result == "gpt-4-turbo"
182-
183-
def test_finds_model_via_private_delegate(self):
184-
"""Test finding agent model through _delegate attribute."""
185-
inner = AgentModelRuntime("gemini-pro")
186-
wrapper = PrivateDelegateRuntime(inner)
187-
result = _find_agent_model_in_runtime(wrapper)
188-
assert result == "gemini-pro"
189-
190-
def test_returns_none_when_no_model(self):
191-
"""Test returns None when no runtime implements the protocol."""
192-
runtime = BaseTestRuntime()
193-
result = _find_agent_model_in_runtime(runtime)
194-
assert result is None
195-
196-
def test_returns_none_for_none_model(self):
197-
"""Test returns None when runtime returns None for model."""
198-
runtime = AgentModelRuntime(None)
199-
result = _find_agent_model_in_runtime(runtime)
200-
assert result is None
201-
202-
203156
class TestGetAgentModel:
204157
"""Tests for _get_agent_model function."""
205158

@@ -235,24 +188,6 @@ async def test_returns_model_consistently(self):
235188

236189
assert model1 == model2 == "consistent-model"
237190

238-
@pytest.mark.asyncio
239-
async def test_handles_exception_gracefully(self, monkeypatch):
240-
"""Test that _get_agent_model returns None when _find_agent_model_in_runtime raises exception."""
241-
runtime = BaseTestRuntime()
242-
schema = MockRuntimeSchema()
243-
244-
# Mock _find_agent_model_in_runtime to raise an exception
245-
def mock_find_agent_model_error(r):
246-
raise RuntimeError("Unexpected error during model lookup")
247-
248-
monkeypatch.setattr(
249-
"uipath._cli.cli_eval._find_agent_model_in_runtime",
250-
mock_find_agent_model_error,
251-
)
252-
253-
model = await _get_agent_model(runtime, schema)
254-
assert model is None
255-
256191

257192
class TestGetSchema:
258193
"""Tests for get_schema method."""
@@ -314,25 +249,3 @@ async def create_runtime():
314249
# Should be the same object
315250
assert schema1 is schema2
316251
assert schema1.file_path == schema2.file_path == "test.py"
317-
318-
319-
class TestWrappedRuntimeModelResolution:
320-
"""Tests for model resolution through realistic wrapper chains."""
321-
322-
def test_resolves_model_through_resumable_telemetry_chain(self):
323-
"""Test model resolution through ResumableRuntime -> TelemetryWrapper -> BaseRuntime chain.
324-
325-
This mimics the real wrapper chain:
326-
UiPathResumableRuntime -> TelemetryRuntimeWrapper -> AgentsLangGraphRuntime
327-
"""
328-
# Base runtime with model
329-
base_runtime = AgentModelRuntime("gpt-4o-from-agent-json")
330-
331-
# Simulate TelemetryRuntimeWrapper
332-
telemetry_wrapper = WrapperRuntime(base_runtime)
333-
334-
# Simulate UiPathResumableRuntime
335-
resumable_runtime = WrapperRuntime(telemetry_wrapper)
336-
337-
model = _find_agent_model_in_runtime(resumable_runtime)
338-
assert model == "gpt-4o-from-agent-json"

0 commit comments

Comments
 (0)