Skip to content

Commit 1a8754a

Browse files
committed
Fix ToolConfigLoader to handle top-level key requirement
- Wrap agent configs in 'agent:' key when loading agent-as-tool - Wrap swarm configs in 'swarm:' key when loading swarm-as-tool - Wrap graph configs in 'graph:' key when loading graph-as-tool - Fixes compatibility with new ConfigLoader top-level key requirement - Resolves agent tool loading errors in configuration-driven systems Fixes issue where agent tools failed to load with: 'Configuration must contain a top-level agent key'
1 parent ffc0bb3 commit 1a8754a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/strands/experimental/config_loader/tools/tool_config_loader.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,10 @@ def _load_swarm_as_tool(self, tool_config: Dict[str, Any]) -> AgentTool:
863863

864864
try:
865865
# Load the swarm using SwarmConfigLoader
866+
# Wrap the swarm config in the required top-level 'swarm' key
866867
swarm_loader = self._get_swarm_config_loader()
867-
swarm = swarm_loader.load_swarm(swarm_config)
868+
wrapped_swarm_config = {"swarm": swarm_config}
869+
swarm = swarm_loader.load_swarm(wrapped_swarm_config)
868870

869871
# Wrap the swarm as a tool
870872
swarm_tool = SwarmAsToolWrapper(
@@ -1045,8 +1047,10 @@ def _load_graph_as_tool(self, tool_config: Dict[str, Any]) -> AgentTool:
10451047

10461048
# Transform the graph configuration to match GraphConfigLoader expectations
10471049
graph_config_copy = self._transform_graph_config(graph_config, entry_point)
1048-
1049-
graph = graph_loader.load_graph(graph_config_copy)
1050+
1051+
# Wrap the graph config in the required top-level 'graph' key
1052+
wrapped_graph_config = {"graph": graph_config_copy}
1053+
graph = graph_loader.load_graph(wrapped_graph_config)
10501054

10511055
# Wrap the graph as a tool
10521056
graph_tool = GraphAsToolWrapper(
@@ -1143,8 +1147,10 @@ def _load_agent_as_tool(self, tool_config: Dict[str, Any]) -> AgentTool:
11431147

11441148
try:
11451149
# Load the agent using AgentConfigLoader
1150+
# Wrap the agent config in the required top-level 'agent' key
11461151
agent_loader = self._get_agent_config_loader()
1147-
agent = agent_loader.load_agent(agent_config)
1152+
wrapped_agent_config = {"agent": agent_config}
1153+
agent = agent_loader.load_agent(wrapped_agent_config)
11481154

11491155
# Wrap the agent as a tool
11501156
agent_tool = AgentAsToolWrapper(

0 commit comments

Comments
 (0)