1212 AgentTerminationException ,
1313)
1414from uipath_langchain .agent .react .terminate_node import create_terminate_node
15- from uipath_langchain .agent .react .types import (
16- AgentTermination ,
17- AgentTerminationSource ,
18- )
1915
2016
2117class MockInnerState (BaseModel ):
2218 """Mock inner state for testing."""
2319
24- termination : AgentTermination | None = None
2520 job_attachments : dict [str , Any ] = {}
2621
2722
@@ -52,19 +47,6 @@ def state_with_human_message(self):
5247 """Fixture for state with human message as last."""
5348 return MockAgentGraphState (messages = [HumanMessage (content = "User message" )])
5449
55- @pytest .fixture
56- def state_with_termination (self ):
57- """Fixture for state with termination set (e.g., escalation)."""
58- termination = AgentTermination (
59- source = AgentTerminationSource .ESCALATION ,
60- title = "Escalation required" ,
61- detail = "User requested human assistance" ,
62- )
63- return MockAgentGraphState (
64- messages = [AIMessage (content = "response" )],
65- inner_state = MockInnerState (termination = termination ),
66- )
67-
6850 def test_conversational_returns_none_no_tool_calls (
6951 self , terminate_node , state_with_ai_message
7052 ):
@@ -82,15 +64,6 @@ def test_conversational_skips_ai_message_validation(
8264
8365 assert result is None
8466
85- def test_conversational_handles_termination (
86- self , terminate_node , state_with_termination
87- ):
88- """Conversational mode should still handle state.inner_state.termination."""
89- with pytest .raises (AgentTerminationException ) as exc_info :
90- terminate_node (state_with_termination )
91-
92- assert "Escalation required" in exc_info .value .error_info .title
93-
9467 def test_conversational_ignores_end_execution_tool (self ):
9568 """Conversational mode should ignore END_EXECUTION tool calls."""
9669 terminate_node = create_terminate_node (
@@ -169,19 +142,6 @@ def state_with_no_control_flow_tool(self):
169142 )
170143 return MockAgentGraphState (messages = [ai_message ])
171144
172- @pytest .fixture
173- def state_with_termination (self ):
174- """Fixture for state with escalation termination."""
175- termination = AgentTermination (
176- source = AgentTerminationSource .ESCALATION ,
177- title = "Needs human review" ,
178- detail = "Complex issue" ,
179- )
180- return MockAgentGraphState (
181- messages = [AIMessage (content = "response" )],
182- inner_state = MockInnerState (termination = termination ),
183- )
184-
185145 def test_non_conversational_handles_end_execution (
186146 self , terminate_node , state_with_end_execution
187147 ):
@@ -223,15 +183,6 @@ def test_non_conversational_raises_on_no_control_flow_tool(
223183 ):
224184 terminate_node (state_with_no_control_flow_tool )
225185
226- def test_non_conversational_handles_termination_first (
227- self , terminate_node , state_with_termination
228- ):
229- """Non-conversational mode should check termination before tool calls."""
230- with pytest .raises (AgentTerminationException ) as exc_info :
231- terminate_node (state_with_termination )
232-
233- assert "Needs human review" in exc_info .value .error_info .title
234-
235186
236187class TestTerminateNodeWithResponseSchema :
237188 """Test cases for terminate node with custom response schema."""
0 commit comments