From a8805b945c9fe5077492454cf50946267755fbb9 Mon Sep 17 00:00:00 2001 From: MavenTheAI Date: Wed, 27 May 2026 20:55:40 -0700 Subject: [PATCH] fix(workflow): treat tools=[] as no tools --- src/strands_tools/workflow.py | 11 +++++++---- tests/test_workflow.py | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/strands_tools/workflow.py b/src/strands_tools/workflow.py index c9dd0555..021ba162 100644 --- a/src/strands_tools/workflow.py +++ b/src/strands_tools/workflow.py @@ -326,17 +326,20 @@ def _create_task_agent(self, task: Dict) -> Agent: # Configure tools filtered_tools = [] - if task_tools and self.parent_agent and hasattr(self.parent_agent, "tool_registry"): + tools_specified = "tools" in task + if tools_specified and self.parent_agent and hasattr(self.parent_agent, "tool_registry"): # Filter parent agent tools to only include specified tool names available_tools = self.parent_agent.tool_registry.registry - for tool_name in task_tools: + for tool_name in (task_tools or []): if tool_name in available_tools: filtered_tools.append(available_tools[tool_name]) else: logger.warning(f"Tool '{tool_name}' not found in parent agent's tool registry") elif self.parent_agent and hasattr(self.parent_agent, "tool_registry"): - # Inherit all tools from parent if none specified - filtered_tools = list(self.parent_agent.tool_registry.registry.values()) + # Inherit all tools from parent if none specified, but exclude workflow to avoid recursion. + filtered_tools = [ + tool for tool_name, tool in self.parent_agent.tool_registry.registry.items() if tool_name != "workflow" + ] # Configure model selected_model = None diff --git a/tests/test_workflow.py b/tests/test_workflow.py index bfc35b3f..f8cce8df 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -390,6 +390,25 @@ def test_create_task_agent_with_tools(self, mock_parent_agent): assert len(call_kwargs["tools"]) == 2 assert call_kwargs["system_prompt"] == "You are a test assistant." + def test_create_task_agent_with_explicit_empty_tools(self, mock_parent_agent): + """Test task agent creation with an explicit empty tools list.""" + with patch("strands_tools.workflow.Agent") as mock_agent_class: + mock_task_agent = MagicMock() + mock_agent_class.return_value = mock_task_agent + + manager = workflow_module.WorkflowManager(mock_parent_agent) + + task = { + "task_id": "test_task", + "description": "Test task", + "tools": [], + } + + manager._create_task_agent(task) + + call_kwargs = mock_agent_class.call_args.kwargs + assert call_kwargs["tools"] == [] + def test_create_task_agent_with_model_provider(self, mock_parent_agent): """Test task agent creation with custom model provider.""" with (