Skip to content

Conversation

@TAKEDA-Takashi
Copy link

Summary

Closes #383

Changes

src/strands_tools/workflow.py

  • Added workflow exclusion guard in the explicit tool list loop (with WARNING log)
  • Changed inherit-all path from one-liner to loop with workflow exclusion (with DEBUG log)

tests/test_workflow.py

  • test_create_task_agent_excludes_workflow_tool_explicit: verifies tools: ["calculator", "workflow"] results in only calculator
  • test_create_task_agent_excludes_workflow_tool_inherit_all: verifies auto-exclusion when inheriting all tools
  • test_create_task_agent_only_workflow_tool_requested: verifies tools: ["workflow"] results in empty list
  • test_create_task_agent_without_workflow_in_registry: regression test when parent has no workflow tool

Relationship to PR #182

This PR is complementary to PR #182 (tools: [] fix). PR #182 fixes the case where an empty tools list is specified; this PR prevents recursion when workflow appears in or is inherited into the tools list. The code changes are in different sections and can coexist.

Test plan

  • hatch fmt --formatter passes
  • hatch fmt --linter passes
  • hatch test tests/test_workflow.py -v — 36 passed
  • hatch test — 1118 passed, 25 skipped, 0 failed

…revent recursion

When _create_task_agent() inherits tools from the parent agent, the
workflow tool itself was included, which could cause infinite recursion
if a task agent invoked the workflow tool again.

This follows the same recursion prevention pattern established by the
think tool (PR strands-agents#167): the workflow tool is automatically excluded from
task agents in both the explicit tool list path and the inherit-all path.

Closes strands-agents#383

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Workflow tool is recursively inherited by task agents, causing infinite loops

2 participants