Skip to content

Isolate shared tools between workflow agents#22165

Open
Kevin-Li-2025 wants to merge 1 commit into
run-llama:mainfrom
Kevin-Li-2025:kevin/isolate-agent-tools
Open

Isolate shared tools between workflow agents#22165
Kevin-Li-2025 wants to merge 1 commit into
run-llama:mainfrom
Kevin-Li-2025:kevin/isolate-agent-tools

Conversation

@Kevin-Li-2025

Copy link
Copy Markdown

Summary

  • copy BaseTool instances when assigning them to workflow agents so the same tool object is not shared across agents by reference
  • copy mutable per-agent tool configuration (metadata, partial_params) without deep-copying heavy callable/retriever/client resources
  • add a regression test covering metadata mutation leakage between two agents initialized with the same FunctionTool

Fixes #22146.

Tests

  • uv run --group dev pytest tests/agent/workflow/test_multi_agent_workflow.py::test_agents_isolate_shared_tool_instances tests/agent/workflow/test_multi_agent_workflow.py::test_basic_workflow tests/agent/workflow/test_multi_agent_workflow.py::test_workflow_requires_root_agent -q
  • uv run --group dev pytest tests/agent/workflow/test_multi_agent_workflow.py -q
  • uv run --group dev ruff check llama_index/core/agent/workflow/base_agent.py tests/agent/workflow/test_multi_agent_workflow.py

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: AgentWorkflow stores agents by reference; one BaseTool instance shared across agents leaks per-tool mutations

1 participant