-
Notifications
You must be signed in to change notification settings - Fork 256
Description
Checks
- I have updated to the lastest minor and patch version of Strands
- I have checked the documentation and this is not expected behavior
- I have searched ./issues and there are no duplicates of my issue
Strands Version
1.23.0
Tools Package Version
0.2.19
Tools used
- workflow
Python Version
3.13.5
Operating System
macOS 26.2
Installation Method
pip
Steps to Reproduce
- Create an agent with the workflow tool:
from strands import Agent
from strands.models.bedrock import BedrockModel
from strands_tools import workflow
model = BedrockModel(
model_id="us.anthropic.claude-3-5-haiku-20241022-v1:0",
region_name="us-east-1",
)
agent = Agent(model=model, tools=[workflow])- Define a simple task without specifying
tools:
tasks = [
{
"task_id": "simple_task",
"description": "Explain what photosynthesis is in one sentence.",
},
]- Create and execute the workflow:
agent.tool.workflow(action="create", workflow_id="test", tasks=tasks)
agent.tool.workflow(action="start", workflow_id="test")- Observe the output - task agent recursively calls workflow tool
Expected Behavior
Task agent should answer the question directly without using any tools, especially not the workflow tool. The task is simple enough that it should just return a text response like "Photosynthesis is the process by which plants convert sunlight into energy."
Task agents should either:
- NOT inherit the workflow tool from the parent agent, OR
- Have automatic recursion prevention (like the
thinktool has per fix(think): implement automatic recursion prevention for think tool #167)
Actual Behavior
Task agent inherits the workflow tool from the parent agent and recursively creates new workflows:
I'll use the workflow tool to generate a concise explanation of photosynthesis...
Tool #1: workflow
Tool #2: workflow
I'll use the workflow tool to create a task that generates a concise explanation...
Tool #1: workflow
Tool #2: workflow
I'll use the workflow tool to create a task that focuses on...
Tool #1: workflow
Tool #2: workflow
... (continues recursively until error or timeout)
Additional Context
Root Cause Analysis:
In workflow.py, the _create_task_agent method inherits all parent tools when tools is not specified in the task definition:
elif self.parent_agent and hasattr(self.parent_agent, "tool_registry"):
filtered_tools = list(self.parent_agent.tool_registry.registry.values())This includes the workflow tool itself, enabling recursive calls.
Workaround:
Adding explicit instruction in system_prompt: "Do not use any tools. Answer with your knowledge only."
tasks = [
{
"task_id": "simple_task",
"description": "Explain what photosynthesis is in one sentence.",
"system_prompt": "Answer concisely. Do not use any tools.",
},
]Possible Solution
Option A: Automatically exclude workflow tool from task agent inheritance
# In _create_task_agent
filtered_tools = [t for t in parent_tools if t.__name__ != 'workflow']Option B: Implement recursion prevention similar to think tool (#167)
Option C: Make tools: [] in task definition actually result in no tools being available (currently it seems to fall through to full inheritance)