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

Merge SwarmAgent into ConversableAgent #316

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

Conversation

marklysze
Copy link
Collaborator

@marklysze marklysze commented Dec 30, 2024

Why are these changes needed?

To expand the use of swarms to allow all ConversableAgent-based agents, this merges SwarmAgent into ConversableAgent.

Progress:

  • Move SwarmAgent-specific init parameters to ConversableAgent
  • Move SwarmAgent initialisation functionality into the a/initiate_swarm_chat functions
  • Move swarm-specific functions under SwarmAgent out, like register_hand_off, _update_conditional_functions, generate_swarm_tool_reply
  • Move/Merge nested chat with carryover into ConversableAgent (process_nested_chat_carryover, _summary_from_nested_chats)
  • Update a/initiate_swarm_chat, AFTER_WORK, ON_CONDITION, SwarmResult, to use ConversableAgent instead of SwarmAgent
  • Move SwarmAgent tests to ConversableAgent tests
  • Update documentation /notebooks referring to SwarmAgent to ConversableAgent
  • Update documentation changing agent.register_hand_off to register_hand_off(agent
  • Add notes to YouTube videos that SwarmAgent is now merged into ConversableAgent

QUESTIONS/NOTES FOR REVIEWER:

  • SwarmAgents could take a list of functions to register (e.g. my_agent = SwarmAgent(functions=[function_a, function_b])). These functions were registered for LLM but not for execution (as a separate agent would execute). How should this work on ConversableAgent? Should it be the same or should there be a way to specify LLM and/or Execution for each function? I have left it as the same for now.
  • In order to show the agent name for a transition function, I have implemented __str__ on ConversableAgent and the associated internal function (_get_display_name()) within it can be overwritten on a ConversableAgent instance, which I've done for any agents associated with a swarm. This means that if you do str(my_conversable_agent) you will get the name of the agent rather than the type as a string.

MIGRATION INSTRUCTIONS:

  • Change SwarmAgent to ConversableAgent
  • Instead of agent.register_hand_off, import and use register_hand_off(agent=abc, ...)
  • UPDATE_SYSTEM_MESSAGE is now UpdateSystemMessage (deprecation warning added)
  • ON_CONDITION is now OnCondition (deprecation warning added)
  • AFTER_WORK is now AfterWork (deprecation warning added)

Related issue number

#26

Checks

@marklysze
Copy link
Collaborator Author

@sonichi, I've updated based on your feedback. I've marked them as resolved but please have a look over and let me know if you have any further thoughts on it. Otherwise, hopefully we can merge.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this file manually maintained or auto-generated? Why is the change?

test/agentchat/test_conversable_agent.py Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

These notebooks won't work before the next release. So If we merge this PR now, we'd better make a release right after merging.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you think we should also do some migration documentation for anyone who is currently using Swarm? Covering SwarmAgent > ConversableAgent + register_hand_off

autogen/agentchat/__init__.py Outdated Show resolved Hide resolved
autogen/agentchat/__init__.py Show resolved Hide resolved
self.register_hook(hookable_method="update_agent_state", hook=create_wrapper(func))

else:
self.register_hook(hookable_method="update_agent_state", hook=func)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have a list of hookable methods in the docstr of ConversableAgent somewhere? Every time we make a change to the list, we should modify that part.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, nothing at the moment, I'll add it in.

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

Successfully merging this pull request may close these issues.

3 participants