fix(workflow): exclude workflow tool from task agent inheritance to prevent recursion #388
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
workflowtool from task agent tool inheritance in_create_task_agent()to prevent infinite recursionthinktool (PR fix(think): implement automatic recursion prevention for think tool #167)Closes #383
Changes
src/strands_tools/workflow.pyworkflowexclusion guard in the explicit tool list loop (withWARNINGlog)workflowexclusion (withDEBUGlog)tests/test_workflow.pytest_create_task_agent_excludes_workflow_tool_explicit: verifiestools: ["calculator", "workflow"]results in onlycalculatortest_create_task_agent_excludes_workflow_tool_inherit_all: verifies auto-exclusion when inheriting all toolstest_create_task_agent_only_workflow_tool_requested: verifiestools: ["workflow"]results in empty listtest_create_task_agent_without_workflow_in_registry: regression test when parent has no workflow toolRelationship 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 whenworkflowappears in or is inherited into the tools list. The code changes are in different sections and can coexist.Test plan
hatch fmt --formatterpasseshatch fmt --linterpasseshatch test tests/test_workflow.py -v— 36 passedhatch test— 1118 passed, 25 skipped, 0 failed