Skip to content

Fix swarm context variable function injection #1264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Mar 10, 2025
Merged

Conversation

marklysze
Copy link
Collaborator

@marklysze marklysze commented Mar 6, 2025

Why are these changes needed?

Registering functions on an agent that goes into a swarm has different implementations based on whether you use the agent's functions parameter when creating or the register_for_llm decorator. This can cause issues in that using the functions parameter does not create a Tool as such, exceptions were being raised.

This aligns them so they both end up creating a Tool and have simplified the approach to hiding parameters on tool schemas for LLMs (essentially uses the same as Dependency Injection).

Related issue number

Closes #1157

Checks

@marklysze marklysze added bug Something isn't working swarm labels Mar 6, 2025
@marklysze marklysze requested a review from davorrunje March 6, 2025 22:01
@marklysze marklysze self-assigned this Mar 6, 2025
@marklysze marklysze added this to ag2 Mar 6, 2025
@marklysze marklysze marked this pull request as draft March 7, 2025 01:14
@marklysze marklysze changed the title Fix swarm tool registration to align with standardised approach Fix swarm context variable function injection Mar 7, 2025
@marklysze marklysze marked this pull request as ready for review March 7, 2025 18:05
@marklysze marklysze added this pull request to the merge queue Mar 10, 2025
Merged via the queue into main with commit b2e6499 Mar 10, 2025
17 checks passed
@marklysze marklysze deleted the fixswarmfuncregister branch March 10, 2025 21:55
@github-project-automation github-project-automation bot moved this to Done in ag2 Mar 10, 2025
Copy link

codecov bot commented Mar 10, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
autogen/agentchat/conversable_agent.py 83.33% 1 Missing ⚠️
Files with missing lines Coverage Δ
autogen/tools/dependency_injection.py 83.80% <100.00%> (+46.66%) ⬆️
autogen/agentchat/conversable_agent.py 67.47% <83.33%> (+50.65%) ⬆️

... and 134 files with indirect coverage changes

🚀 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
bug Something isn't working swarm
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[Bug]: Functions registered in a swarm may not be returning the correct SwarmResult
2 participants