File tree Expand file tree Collapse file tree
src/uipath_langchain/agent/guardrails/actions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3+ import ast
34import json
45import re
56from typing import Any , Dict , Literal , cast
@@ -507,7 +508,23 @@ def _extract_tool_escalation_content(
507508 else :
508509 if not isinstance (message , ToolMessage ):
509510 return ""
510- return message .content
511+ content = message .content
512+
513+ # If content is already dict/list, serialize to JSON
514+ if isinstance (content , (dict , list )):
515+ return json .dumps (content )
516+
517+ # If content is a string that looks like a Python literal, convert to JSON
518+ if isinstance (content , str ):
519+ try :
520+ # Try to parse as Python literal and convert to JSON
521+ parsed_content = ast .literal_eval (content )
522+ return json .dumps (parsed_content )
523+ except (ValueError , SyntaxError ):
524+ # If parsing fails, return as-is
525+ pass
526+
527+ return content
511528
512529
513530def _execution_stage_to_escalation_field (
You can’t perform that action at this time.
0 commit comments