@@ -603,3 +603,92 @@ def test_tool_registry_replace_non_dynamic_with_dynamic():
603603
604604 assert registry .registry ["my_tool" ] == new_tool
605605 assert registry .dynamic_tools ["my_tool" ] == new_tool
606+
607+
608+ # --- Agent-as-tool sugar ---
609+
610+
611+ def test_process_tools_with_agent_instance ():
612+ """Test that passing an Agent instance in tools list auto-wraps it with as_tool()."""
613+ from strands .agent .agent import Agent
614+
615+ sub_agent = Agent (name = "research_agent" , description = "Finds information" , callback_handler = None )
616+
617+ registry = ToolRegistry ()
618+ tool_names = registry .process_tools ([sub_agent ])
619+
620+ assert "research_agent" in tool_names
621+ assert "research_agent" in registry .registry
622+ assert registry .registry ["research_agent" ].tool_type == "agent"
623+
624+
625+ def test_process_tools_with_agent_instance_uses_agent_name ():
626+ """Test that the auto-wrapped tool uses the agent's name."""
627+ from strands .agent .agent import Agent
628+
629+ sub_agent = Agent (name = "my_custom_agent" , callback_handler = None )
630+
631+ registry = ToolRegistry ()
632+ registry .process_tools ([sub_agent ])
633+
634+ assert "my_custom_agent" in registry .registry
635+ spec = registry .registry ["my_custom_agent" ].tool_spec
636+ assert spec ["name" ] == "my_custom_agent"
637+
638+
639+ def test_process_tools_with_agent_instance_uses_agent_description ():
640+ """Test that the auto-wrapped tool uses the agent's description."""
641+ from strands .agent .agent import Agent
642+
643+ sub_agent = Agent (name = "helper" , description = "A helpful assistant" , callback_handler = None )
644+
645+ registry = ToolRegistry ()
646+ registry .process_tools ([sub_agent ])
647+
648+ spec = registry .registry ["helper" ].tool_spec
649+ assert spec ["description" ] == "A helpful assistant"
650+
651+
652+ def test_process_tools_with_agent_in_nested_list ():
653+ """Test that Agent instances in nested iterables are auto-wrapped."""
654+ from strands .agent .agent import Agent
655+
656+ agent_a = Agent (name = "agent_a" , callback_handler = None )
657+ agent_b = Agent (name = "agent_b" , callback_handler = None )
658+
659+ registry = ToolRegistry ()
660+ tool_names = sorted (registry .process_tools ([[agent_a , agent_b ]]))
661+
662+ assert tool_names == ["agent_a" , "agent_b" ]
663+
664+
665+ def test_process_tools_with_mixed_agents_and_tools ():
666+ """Test that Agent instances can be mixed with regular tools."""
667+ from strands .agent .agent import Agent
668+
669+ def function () -> str :
670+ return "done"
671+
672+ regular_tool = tool (name = "regular_tool" )(function )
673+ sub_agent = Agent (name = "sub_agent" , callback_handler = None )
674+
675+ registry = ToolRegistry ()
676+ tool_names = sorted (registry .process_tools ([regular_tool , sub_agent ]))
677+
678+ assert tool_names == ["regular_tool" , "sub_agent" ]
679+ assert registry .registry ["sub_agent" ].tool_type == "agent"
680+
681+
682+ def test_process_tools_with_multiple_agents ():
683+ """Test that multiple Agent instances can be passed."""
684+ from strands .agent .agent import Agent
685+
686+ agent_1 = Agent (name = "researcher" , description = "Does research" , callback_handler = None )
687+ agent_2 = Agent (name = "writer" , description = "Writes content" , callback_handler = None )
688+ agent_3 = Agent (name = "reviewer" , description = "Reviews work" , callback_handler = None )
689+
690+ registry = ToolRegistry ()
691+ tool_names = sorted (registry .process_tools ([agent_1 , agent_2 , agent_3 ]))
692+
693+ assert tool_names == ["researcher" , "reviewer" , "writer" ]
694+ assert all (registry .registry [name ].tool_type == "agent" for name in tool_names )
0 commit comments