Skip to content

Commit 91049df

Browse files
authored
fix(eval): trim legacy trajectory span history (#1653)
1 parent 67c4d0b commit 91049df

4 files changed

Lines changed: 68 additions & 7 deletions

File tree

packages/uipath/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath"
3-
version = "2.10.65"
3+
version = "2.10.66"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

packages/uipath/src/uipath/eval/evaluators/legacy_trajectory_evaluator.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
from ..._utils.constants import COMMUNITY_agents_SUFFIX
1414
from .._execution_context import eval_set_run_id_context
15+
from .._helpers.evaluators_helpers import trace_to_str
1516
from .._helpers.helpers import is_empty_value
1617
from ..models import EvaluationResult
1718
from ..models.models import (
1819
AgentExecution,
1920
LLMResponse,
2021
NumericEvaluationResult,
21-
TrajectoryEvaluationTrace,
2222
UiPathEvaluationError,
2323
UiPathEvaluationErrorCategory,
2424
)
@@ -140,10 +140,7 @@ def _create_evaluation_prompt(
140140
and agent_run_history
141141
and isinstance(agent_run_history[0], ReadableSpan)
142142
):
143-
trajectory_trace = TrajectoryEvaluationTrace.from_readable_spans(
144-
agent_run_history
145-
)
146-
agent_run_history = str(trajectory_trace.spans)
143+
agent_run_history = trace_to_str(agent_run_history)
147144
else:
148145
agent_run_history = str(agent_run_history)
149146

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import uuid
2+
3+
from opentelemetry.sdk.trace import ReadableSpan
4+
5+
from uipath.eval.evaluators import LegacyTrajectoryEvaluator
6+
from uipath.eval.evaluators.base_legacy_evaluator import LegacyEvaluationCriteria
7+
from uipath.eval.evaluators.legacy_trajectory_evaluator import (
8+
LegacyTrajectoryEvaluatorConfig,
9+
)
10+
from uipath.eval.models.models import LegacyEvaluatorCategory, LegacyEvaluatorType
11+
12+
13+
def _legacy_trajectory_evaluator() -> LegacyTrajectoryEvaluator:
14+
return LegacyTrajectoryEvaluator(
15+
id=str(uuid.uuid4()),
16+
name="Legacy trajectory",
17+
config_type=LegacyTrajectoryEvaluatorConfig,
18+
evaluation_criteria_type=LegacyEvaluationCriteria,
19+
justification_type=str,
20+
category=LegacyEvaluatorCategory.Trajectory,
21+
type=LegacyEvaluatorType.Trajectory,
22+
prompt="History:\n{{AgentRunHistory}}\nExpected:\n{{ExpectedAgentBehavior}}",
23+
createdAt="2026-05-14T00:00:00Z",
24+
updatedAt="2026-05-14T00:00:00Z",
25+
)
26+
27+
28+
def test_legacy_trajectory_prompt_uses_compact_tool_history() -> None:
29+
long_prompt = "SYSTEM_PROMPT_" + ("x" * 10_000)
30+
spans = [
31+
ReadableSpan(
32+
name="agent_llm_call",
33+
start_time=0,
34+
end_time=1,
35+
attributes={
36+
"openinference.span.kind": "LLM",
37+
"input.value": f'{{"messages": [{{"role": "system", "content": "{long_prompt}"}}]}}',
38+
"output.value": '{"generations": []}',
39+
},
40+
),
41+
ReadableSpan(
42+
name="search_profiles",
43+
start_time=1,
44+
end_time=2,
45+
attributes={
46+
"openinference.span.kind": "TOOL",
47+
"tool.name": "search_profiles",
48+
"input.value": '{"query": "mentor"}',
49+
"output.value": '{"content": "found mentor profile"}',
50+
"metadata": f'{{"agent_prompt": "{long_prompt}"}}',
51+
},
52+
),
53+
]
54+
55+
prompt = _legacy_trajectory_evaluator()._create_evaluation_prompt(
56+
expected_agent_behavior="The agent should search matching profiles.",
57+
agent_run_history=spans,
58+
)
59+
60+
assert "SYSTEM_PROMPT_" not in prompt
61+
assert "Tool: search_profiles" in prompt
62+
assert '{"query": "mentor"}' in prompt
63+
assert "found mentor profile" in prompt
64+
assert "agent_llm_call" not in prompt

packages/uipath/uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)