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 Team Config Serializable #5071

Merged
merged 13 commits into from
Jan 24, 2025
Merged

Conversation

victordibia
Copy link
Collaborator

@victordibia victordibia commented Jan 16, 2025

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

All modified and coverable lines are covered by tests ✅

Project coverage is 70.80%. Comparing base (58d789a) to head (b598377).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5071      +/-   ##
==========================================
+ Coverage   70.53%   70.80%   +0.27%     
==========================================
  Files         174      174              
  Lines       11129    11229     +100     
==========================================
+ Hits         7850     7951     +101     
+ Misses       3279     3278       -1     
Flag Coverage Δ
unittests 70.80% <100.00%> (+0.27%) ⬆️

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

victordibia commented Jan 21, 2025

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

Edit: Resolution -> we are moving to ABC's for components.

@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.

@victordibia victordibia changed the title Make AgentChat Teams Declarative Make AgentChat Team Config Serializable Jan 23, 2025
@victordibia victordibia marked this pull request as ready for review January 23, 2025 02:46
@victordibia victordibia requested review from ekzhu and jackgerrits and removed request for ekzhu January 23, 2025 17:15
@victordibia victordibia enabled auto-merge (squash) January 24, 2025 04:20
@victordibia victordibia disabled auto-merge January 24, 2025 04:20
@victordibia victordibia enabled auto-merge (squash) January 24, 2025 04:38
@victordibia victordibia merged commit 979d8ab into main Jan 24, 2025
64 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
3 participants