@@ -242,7 +242,7 @@ async def test_node_post_execution_tool_field(self, mock_interrupt):
242242
243243 # Verify ToolOutputs is used for PostExecution
244244 call_args = mock_interrupt .call_args [0 ][0 ]
245- assert call_args .data ["Outputs" ] == '[ "Test response"]'
245+ assert call_args .data ["Outputs" ] == "Test response"
246246 assert "Inputs" not in call_args .data
247247
248248 @pytest .mark .asyncio
@@ -287,12 +287,13 @@ async def test_post_execution_ai_message_with_tool_calls_extraction(
287287
288288 await node (state )
289289
290- # Verify interrupt was called with tool calls and content in ToolOutputs
290+ # Verify interrupt was called with tool calls (name and args) in ToolOutputs
291291 call_args = mock_interrupt .call_args [0 ][0 ]
292292 tool_outputs = call_args .data ["Outputs" ]
293293 parsed = json .loads (tool_outputs )
294- assert len (parsed ) == 2 # Tool call content + message content
295- assert parsed [1 ] == "AI response"
294+ assert len (parsed ) == 1 # Tool call data with name and args
295+ assert parsed [0 ]["name" ] == "test_tool"
296+ assert parsed [0 ]["args" ] == {"content" : {"input" : "test" }}
296297
297298 @pytest .mark .asyncio
298299 @patch ("uipath_langchain.agent.guardrails.actions.escalate_action.interrupt" )
@@ -367,10 +368,10 @@ async def test_post_execution_human_message_with_reviewed_outputs(
367368
368369 result = await node (state )
369370
370- # Verify HumanMessage content was updated (ignores tool calls )
371+ # Verify HumanMessage content was updated with fallback (raw JSON string )
371372 assert isinstance (result , Command )
372373 assert result .update is not None
373- assert result .update ["messages" ][0 ].content == "Updated content"
374+ assert result .update ["messages" ][0 ].content == json . dumps ( reviewed_content )
374375
375376 @pytest .mark .asyncio
376377 @patch ("uipath_langchain.agent.guardrails.actions.escalate_action.interrupt" )
@@ -388,12 +389,8 @@ async def test_post_execution_ai_message_with_reviewed_outputs_and_tool_calls(
388389 guardrail .name = "Test Guardrail"
389390 guardrail .description = "Test description"
390391
391- reviewed_tool_content = {"updated" : "tool_content" }
392- reviewed_message_content = "Updated message"
393- reviewed_outputs = [
394- json .dumps (reviewed_tool_content ),
395- reviewed_message_content ,
396- ]
392+ reviewed_tool_args = {"updated" : "tool_content" }
393+ reviewed_outputs = [{"name" : "test_tool" , "args" : reviewed_tool_args }]
397394 mock_escalation_result = MagicMock ()
398395 mock_escalation_result .action = "Approve"
399396 mock_escalation_result .data = {"ReviewedOutputs" : json .dumps (reviewed_outputs )}
@@ -420,12 +417,11 @@ async def test_post_execution_ai_message_with_reviewed_outputs_and_tool_calls(
420417
421418 result = await node (state )
422419
423- # Verify tool calls and message content were updated
420+ # Verify tool calls args were updated by matching name
424421 assert isinstance (result , Command )
425422 assert result .update is not None
426423 updated_message = result .update ["messages" ][0 ]
427- assert updated_message .tool_calls [0 ]["args" ]["content" ] == reviewed_tool_content
428- assert updated_message .content == reviewed_message_content
424+ assert updated_message .tool_calls [0 ]["args" ] == reviewed_tool_args
429425
430426 @pytest .mark .asyncio
431427 @patch ("uipath_langchain.agent.guardrails.actions.escalate_action.interrupt" )
@@ -1206,7 +1202,7 @@ async def test_extract_llm_content_pre_execution_empty_content(self):
12061202
12071203 @pytest .mark .asyncio
12081204 async def test_extract_llm_content_post_execution_tool_calls_no_content_field (self ):
1209- """Extract LLM content PostExecution: tool calls without content field are skipped ."""
1205+ """Extract LLM content PostExecution: extracts all tool calls with name and args ."""
12101206 from uipath_langchain .agent .guardrails .actions .escalate_action import (
12111207 _extract_llm_escalation_content ,
12121208 )
@@ -1227,9 +1223,10 @@ async def test_extract_llm_content_post_execution_tool_calls_no_content_field(se
12271223
12281224 assert isinstance (result , str )
12291225 parsed = json .loads (result )
1230- # Should only contain message content, not tool call content
1226+ # Should extract tool call data with name and args
12311227 assert len (parsed ) == 1
1232- assert parsed [0 ] == "Response"
1228+ assert parsed [0 ]["name" ] == "tool_without_content"
1229+ assert parsed [0 ]["args" ] == {"param" : "value" }
12331230
12341231 @pytest .mark .asyncio
12351232 async def test_extract_escalation_content_empty_messages_raises_exception (self ):
0 commit comments