Skip to content

Commit d5b66d1

Browse files
committed
refactor: rename and add is error check
1 parent 451cd1f commit d5b66d1

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/uipath_langchain/agent/react/agent.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,22 @@ def create_agent(
8181
llm_tools: list[BaseTool] = [*agent_tools, *flow_control_tools]
8282

8383
# Derive client-side tool schemas from tools for input validation in the init node.
84-
cs_tools: dict[str, ClientSideToolInfo] | None = None
84+
conversational_client_side_tools: dict[str, ClientSideToolInfo] | None = None
8585
if config.is_conversational:
86-
cs_tools = {}
86+
conversational_client_side_tools = {}
8787
for t in agent_tools:
8888
meta = getattr(t, "metadata", None) or {}
8989
if meta.get(IS_CONVERSATIONAL_CLIENT_SIDE_TOOL):
90-
cs_tools[t.name] = {
90+
conversational_client_side_tools[t.name] = {
9191
"input_schema": t.args_schema.model_json_schema()
9292
if hasattr(t, "args_schema") and t.args_schema
9393
else None,
9494
"output_schema": meta.get("output_schema"),
9595
}
96-
cs_tools = cs_tools or None
96+
conversational_client_side_tools = conversational_client_side_tools or None
9797

9898
init_node = create_init_node(
99-
messages, input_schema, config.is_conversational, cs_tools
99+
messages, input_schema, config.is_conversational, conversational_client_side_tools
100100
)
101101

102102
tool_nodes = create_tool_node(agent_tools)

src/uipath_langchain/agent/tools/client_side_tool.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,21 +98,25 @@ async def wait_for_client_execution() -> dict[str, Any]:
9898
}
9999

100100
result = await wait_for_client_execution()
101-
return result.get("output", result) if isinstance(result, dict) else result
101+
return result if isinstance(result, dict) else {"output": result}
102102

103103
result = await execute_tool()
104104

105-
if isinstance(result, dict):
105+
is_error = result.get("isError", False)
106+
output = result.get("output", result)
107+
108+
if isinstance(output, dict):
106109
try:
107-
content = json.dumps(result)
110+
content = json.dumps(output)
108111
except TypeError:
109-
content = str(result)
112+
content = str(output)
110113
else:
111-
content = str(result) if result is not None else ""
114+
content = str(output) if output is not None else ""
112115

113116
return ToolMessage(
114117
content=content,
115118
tool_call_id=tool_call_id,
119+
status="error" if is_error else "success",
116120
response_metadata={IS_CONVERSATIONAL_CLIENT_SIDE_TOOL: True},
117121
)
118122

0 commit comments

Comments
 (0)