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

Agentchat refactor #4062

Merged
merged 6 commits into from
Nov 5, 2024
Merged

Agentchat refactor #4062

merged 6 commits into from
Nov 5, 2024

Conversation

ekzhu
Copy link
Collaborator

@ekzhu ekzhu commented Nov 5, 2024

  1. Make events internal to group chat and log the agent messages directly with simplified implementation. Basic usage case will just use run_stream to see the stream of messages rather than relying on logs to get agent chats. Decoupling presentation logics from execution.

  2. Move message thread to team from group chat manager, so the team can maintain the message thread state for resume.

# Create team
terminate = TokenUsageTermination(...)
team = Swarm(..., termination_condition=terminate)

# First run
result1 = await team.run("task ...")

# Reset termination condition and run again with the same team and agent state.
await terminate.reset()
result2 = await team.run("task ...")
  1. Expose termination stop reason in task result
result = await team.run("some task")
print(result.stop_reason)
Text 'TERMINATE' mentioned
  1. Expose inner messages to termination conditions, so condition on inner messages, such as token usage, can be applied correctly.

Next step:

  1. document resume of team by calling run again.
  2. inject agent & team state through built-in memory module Memory Interface for AgentChat agents #4039

@ekzhu ekzhu marked this pull request as ready for review November 5, 2024 05:06
@ekzhu ekzhu requested review from victordibia, afourney, gagb, binary-husky and husseinmozannar and removed request for binary-husky November 5, 2024 05:06
Copy link
Collaborator

@victordibia victordibia left a comment

Choose a reason for hiding this comment

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

Good first implementation.
+1 on returning stop_message.
Useful for applications to keep track of reasons the task ended. (similar to finish_reason in the oai api)

@ekzhu ekzhu merged commit c3283c6 into main Nov 5, 2024
38 checks passed
@ekzhu ekzhu deleted the agentchat-refactor branch November 5, 2024 16:07
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.

2 participants