@@ -173,6 +173,13 @@ def test_route_workflow(self):
173173 route_workflow ({"next_worker" : "common_agent" , "messages" : [dummy_msg ]}), "common_agent"
174174 )
175175
176+ def test_route_workflow_unknown (self ):
177+ """Test routing with an unknown worker."""
178+ dummy_msg = HumanMessage (content = "test" )
179+ self .assertEqual (
180+ route_workflow ({"next_worker" : "unknown" , "messages" : [dummy_msg ]}), "unknown"
181+ )
182+
176183 def test_route_after_worker (self ):
177184 """Test routing logic after a worker agent finishes."""
178185 # Tool calls present -> route to tools
@@ -241,6 +248,21 @@ def test_detect_tool_loop(self):
241248 }
242249 self .assertTrue (detect_tool_loop (state_alternating ))
243250
251+ def test_detect_tool_loop_different_args (self ):
252+ """Test that same tool with different args is not a loop."""
253+ call_a = {"name" : "tool_a" , "args" : {"x" : 1 }, "id" : "1" }
254+ call_b = {"name" : "tool_a" , "args" : {"x" : 2 }, "id" : "2" }
255+ state = {
256+ "messages" : [
257+ AIMessage (content = "" , tool_calls = [call_a ]),
258+ ToolMessage (content = "res" , tool_call_id = "1" , name = "tool_a" ),
259+ AIMessage (content = "" , tool_calls = [call_b ]),
260+ ToolMessage (content = "res" , tool_call_id = "2" , name = "tool_a" ),
261+ AIMessage (content = "" , tool_calls = [call_a ]),
262+ ]
263+ }
264+ self .assertFalse (detect_tool_loop (state ))
265+
244266 def test_route_after_worker_loop_detection (self ):
245267 """Test that route_after_worker catches loops."""
246268 tool_call = {"name" : "tool_a" , "args" : {"x" : 1 }, "id" : "1" }
@@ -578,6 +600,17 @@ def test_update_step_status(self):
578600 self .assertEqual (steps_status [0 ], "completed" )
579601 self .assertEqual (steps_status [1 ], "skipped" )
580602
603+ def test_update_step_status_invalid_id (self ):
604+ """Test update_step_status with an ID that doesn't exist."""
605+ steps_status = ["pending" ]
606+ decision = MagicMock ()
607+ decision .current_step_id = 99
608+ decision .current_step_status = "completed"
609+ decision .skipped_step_ids = []
610+
611+ update_step_status (decision , steps_status )
612+ self .assertEqual (steps_status [0 ], "pending" )
613+
581614 def test_check_completion (self ):
582615 decision = MagicMock ()
583616 decision .next_worker = "supervisor"
0 commit comments