Skip to content

Commit 5f5501a

Browse files
authored
Merge pull request #795 from UiPath/fix/toolcall-justification-error
fix: resolve eval run JSON serialization and API validation errors
2 parents a607677 + d068a74 commit 5f5501a

3 files changed

Lines changed: 29 additions & 5 deletions

File tree

‎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.1.115"
3+
version = "2.1.116"
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.10"

‎src/uipath/_cli/_evals/_progress_reporter.py‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,24 @@ async def subscribe_to_eval_runtime_events(self, event_bus: EventBus) -> None:
478478

479479
logger.debug("StudioWeb progress reporter subscribed to evaluation events")
480480

481+
def _serialize_justification(self, justification: Any) -> str | None:
482+
"""Serialize justification to JSON string for API compatibility.
483+
484+
Args:
485+
justification: The justification object which could be None, a BaseModel,
486+
a string, or any other JSON-serializable object
487+
488+
Returns:
489+
JSON string representation or None if justification is None
490+
"""
491+
if justification is None:
492+
return None
493+
if hasattr(justification, "model_dump"):
494+
return json.dumps(justification.model_dump())
495+
if not isinstance(justification, str):
496+
return json.dumps(justification)
497+
return justification
498+
481499
def _extract_agent_snapshot(self, entrypoint: str) -> StudioWebAgentSnapshot:
482500
try:
483501
project_config = get_project_config(os.getcwd())
@@ -531,11 +549,14 @@ def _collect_results(
531549
uuid.uuid5(uuid.NAMESPACE_DNS, eval_result.evaluator_id)
532550
)
533551

552+
# Convert BaseModel justification to JSON string for API compatibility
553+
justification = self._serialize_justification(eval_result.result.details)
554+
534555
evaluator_scores_list.append(
535556
{
536557
"type": eval_result.result.score_type.value,
537558
"value": eval_result.result.score,
538-
"justification": eval_result.result.details,
559+
"justification": justification,
539560
"evaluatorId": evaluator_id_value,
540561
}
541562
)
@@ -586,11 +607,14 @@ def _collect_coded_results(
586607
if eval_result.evaluator_id not in evaluators:
587608
continue
588609

610+
# Convert BaseModel justification to JSON string for API compatibility
611+
justification = self._serialize_justification(eval_result.result.details)
612+
589613
evaluator_scores_list.append(
590614
{
591615
"type": eval_result.result.score_type.value,
592616
"value": eval_result.result.score,
593-
"justification": eval_result.result.details,
617+
"justification": justification,
594618
"evaluatorId": eval_result.evaluator_id,
595619
}
596620
)
@@ -603,7 +627,7 @@ def _collect_coded_results(
603627
"type": eval_result.result.score_type.value,
604628
"value": eval_result.result.score,
605629
},
606-
"justification": eval_result.result.details,
630+
"justification": justification,
607631
},
608632
"completionMetrics": {
609633
"duration": int(eval_result.result.evaluation_time)

‎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)