Skip to content
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

Make AgentChat Teams Declarative #5071

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

victordibia
Copy link
Collaborator

Why are these changes needed?

Support a developer experience where an AgentChat team configuration can be serialized to a declarative specification.

# dump
agent = AssistantAgent(
    name="assistant",
    model_client=model_client,
    handoffs=["flights_refunder", "user"],
    tools=[web_search],
    system_message="Use tools to solve tasks.",
)
team = RoundRobinGroupChat(participants=[agent], ...)
team_spec = team.dump_component() 

TBD

Related issue number

Closes #5064

Checks

Copy link

codecov bot commented Jan 16, 2025

Codecov Report

Attention: Patch coverage is 96.19048% with 4 lines in your changes missing coverage. Please review.

Project coverage is 70.61%. Comparing base (0363388) to head (451757f).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...autogen_agentchat/agents/_society_of_mind_agent.py 78.94% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5071      +/-   ##
==========================================
+ Coverage   69.91%   70.61%   +0.70%     
==========================================
  Files         168      174       +6     
  Lines       10698    11111     +413     
==========================================
+ Hits         7479     7846     +367     
- Misses       3219     3265      +46     
Flag Coverage Δ
unittests 70.61% <96.19%> (+0.70%) ⬆️

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.

@victordibia
Copy link
Collaborator Author

Some updates on this effort on here so we can have a broader discussion.

There are a few current issues with making teams declarative (or more generally - elements that inherit from a protocol cannot be declarative in the current setup without mypy/build errors).

The short story is that:

  • the inheritance structure for Agents is ChatAgent ->BaseChatAgent -> AssistantAgent.
    • ChatAgent is a protocol .. it cannot be declarative/component as it can only inherit from protocols
    • BaseChatAgent is an abstract class and can be made a component .. so this is where component behaviors for agents begin
  • Teams (e,g RoundRobinGroupChat, Selector ...) have a participants arg which is typed as List[ChatAgent]
    • However, when we serialize/deserialize we can only return BaseChatAgent classes
      Mypy/pyright throw errors ... ChatAgent does not have dump_component etc

Similar situation with SocietyofMindAgent. It has a team field that inherits from the Team protocol. While we can serialize base Team classes, mypy still fails as the Team protocol itself cannot cannot inherit from ComponentBase.

Some potential solutions/directions

  • update participants type to List[BaseChatAgent] instead of ChatAgent (has its own issues)
  • Make ChatAgent an abstract class - not a protocol ...(seems we mix protocol and base class inheritance a few times in agentchat ...)
  • Modify Component config design to accomodate Protocol?
  • Something else ..

@ekzhu , @jackgerrits

@ekzhu
Copy link
Collaborator

ekzhu commented Jan 22, 2025

Just a comment on the name. This work is not to make agent chat declarative -- the agentchat API is already declartive.

It is to make the configuration serializable. So should update the title and fix how we mention it for precise language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants