KEMBAR78
Feat/tool call loop by tejas-dharani · Pull Request #6651 · microsoft/autogen · GitHub
Skip to content

Conversation

@tejas-dharani
Copy link
Contributor

@tejas-dharani tejas-dharani commented Jun 9, 2025

Why are these changes needed?

This PR addresses critical issues in the AssistantAgent that affect tool handling:

Lack of tool call loop functionality: The agent could not perform multiple consecutive tool calls in a single turn, limiting its ability to complete complex multi-step tasks that require chaining tool operations.

These changes enhance the agent's robustness and capability while maintaining full backward compatibility through feature flags.

Related issue number

Closes #6268

Checks

…on guide- Fix version format from 0.4.0-dev-1 to 0.4.0-dev.1 for all packages- Remove reference to non-existent Microsoft.AutoGen.Extensions package- Add correct extension packages: Aspire, MEAI, and SemanticKernel- Fix typo: RuntimeGatewway -> RuntimeGateway- Improve documentation structure with clear section headersFixes #6244
Fix issue #6277 where TextMessage was used but not imported in three code cells
of the custom agents documentation, causing NameError when users run the examples.

Changes:
- Add TextMessage to imports in ArithmeticAgent section
- Add TextMessage to imports in GeminiAssistantAgent section
- Add TextMessage to imports in Declarative GeminiAssistantAgent section

The CountDownAgent section already had the correct import.

Fixes #6277
- Fix missing tools parameter in reflection flow (Issue #6328)
- Add tool_call_loop parameter for repeated tool calls (Issue #6268)
- Maintain backward compatibility (both features disabled by default)
- Add comprehensive tests and documentation

Resolves: #6328, #6268
@codecov
Copy link

codecov bot commented Jun 9, 2025

Codecov Report

Attention: Patch coverage is 93.90244% with 5 lines in your changes missing coverage. Please review.

Project coverage is 79.85%. Comparing base (2b873a4) to head (e2f2ee7).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...t/src/autogen_agentchat/agents/_assistant_agent.py 93.90% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6651   +/-   ##
=======================================
  Coverage   79.84%   79.85%           
=======================================
  Files         232      232           
  Lines       17513    17540   +27     
=======================================
+ Hits        13983    14006   +23     
- Misses       3530     3534    +4     
Flag Coverage Δ
unittests 79.85% <93.90%> (+<0.01%) ⬆️

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.

Copy link
Collaborator

@ekzhu ekzhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the changes to the dotnet package?

The changes looks very much not ready for review. For example, the tests added are not addressing the tool call loo. I am moving it to the draft state.

If others would like to submit a separate PR for the same issue it's okay too.

@ekzhu ekzhu marked this pull request as draft June 18, 2025 00:00
@tejas-dharani
Copy link
Contributor Author

Can you remove the changes to the dotnet package?

The changes looks very much not ready for review. For example, the tests added are not addressing the tool call loo. I am moving it to the draft state.

If others would like to submit a separate PR for the same issue it's okay too.

Ok , I will make changes and Make it proper.

…stallation guide- Fix version format from 0.4.0-dev-1 to 0.4.0-dev.1 for all packages- Remove reference to non-existent Microsoft.AutoGen.Extensions package- Add correct extension packages: Aspire, MEAI, and SemanticKernel- Fix typo: RuntimeGatewway -> RuntimeGateway- Improve documentation structure with clear section headersFixes #6244"

This reverts commit 6d9fb2e.
@tejas-dharani tejas-dharani marked this pull request as ready for review June 19, 2025 10:41
@tejas-dharani tejas-dharani changed the title Feat/tool call loop and reflection fix Feat/tool call loop Jun 21, 2025
…loop_config parameter

- Change while loop to for loop for better code readability
- Remove reflection flow changes as per reviewer feedback
@tejas-dharani
Copy link
Contributor Author

Hello @ekzhu Sir,
Can you review the changes again Sir ?

@tejas-dharani tejas-dharani requested a review from ekzhu June 27, 2025 07:36
Copy link
Collaborator

@ekzhu ekzhu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to further simplify:

  1. Use a single integer argument "max_tool_call_iteration" defaults to 1.
  2. Remove changes not related to this addition. Eg to the replay client

tejas-dharani and others added 7 commits June 28, 2025 17:32
Resolved conflicts by:
- Merging tool call loop implementation with streaming tool execution
- Adding message ID support to tool call loops
- Updating imports to include StaticStreamWorkbench and ToolResult
- Combining streaming tool execution with existing loop logic
- Fixed test conflicts by removing orphaned code

The merged implementation preserves both the tool call loop functionality
and the streaming capabilities from main branch.
@ekzhu ekzhu merged commit 6f15270 into microsoft:main Jun 29, 2025
66 checks passed
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.

Support repeated tool calls in a loop within AssistantAgent

2 participants