KEMBAR78
Add documentation warnings for AgentTool/TeamTool parallel tool calls limitation by Copilot · Pull Request #6883 · microsoft/autogen · GitHub
Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 31, 2025

When using AgentTool or TeamTool with parallel tool calls enabled (the default), the second tool execution fails with "The team is already running, it cannot run again until it is stopped." This occurs because teams and agents maintain internal state that conflicts with concurrent execution.

The issue manifests when an LLM makes multiple tool calls simultaneously:

# This fails when the model makes parallel tool calls
main_agent = AssistantAgent(
    name="main_agent",
    model_client=model_client,  # parallel_tool_calls=True by default
    tools=[team_tool],
)

# The LLM might generate:
# [FunctionCall(name='writing_team', ...), FunctionCall(name='writing_team', ...)]
# Second call fails: "The team is already running"

Solution: Users must disable parallel tool calls when using these tools:

# Correct usage - disable parallel tool calls
model_client = OpenAIChatCompletionClient(model="gpt-4", parallel_tool_calls=False)
main_agent = AssistantAgent(
    name="main_agent", 
    model_client=model_client,
    tools=[team_tool],
)

This PR adds comprehensive documentation warnings:

  1. Tutorial documentation (agents.ipynb): Added prominent warning in the Parallel Tool Calls section explaining the limitation and solution
  2. TeamTool docstring: Added .. important:: directive with clear explanation and updated example showing proper usage
  3. AgentTool docstring: Added matching warning and example demonstrating parallel_tool_calls=False

All examples now show the correct pattern of creating separate model clients with parallel tool calls disabled for the main agent while allowing the wrapped agents/teams to use their own model clients normally.

Fixes #6882.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Copilot AI changed the title [WIP] TeamTool fails to execute twice for one Agent Add documentation warnings for AgentTool/TeamTool parallel tool calls limitation Jul 31, 2025
Copilot AI requested a review from ekzhu July 31, 2025 13:40
Copilot finished work on behalf of ekzhu July 31, 2025 13:40
@ekzhu ekzhu marked this pull request as ready for review August 2, 2025 00:11
@ekzhu ekzhu merged commit 3e30f9e into main Aug 2, 2025
36 of 60 checks passed
@ekzhu ekzhu deleted the copilot/fix-6882 branch August 2, 2025 00:19
@codecov
Copy link

codecov bot commented Aug 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.92%. Comparing base (c1e4ae6) to head (2740fac).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6883   +/-   ##
=======================================
  Coverage   80.92%   80.92%           
=======================================
  Files         237      237           
  Lines       18289    18289           
=======================================
  Hits        14801    14801           
  Misses       3488     3488           
Flag Coverage Δ
unittests 80.92% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

TeamTool fails to execute twice for one Agent

2 participants