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

Add Optional Async Shutdown Method to BaseChatAgent and BaseGroupChat for Cleanup Operations #3850

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ async def on_messages(self, messages: Sequence[ChatMessage], cancellation_token:
"""Handle incoming messages and return a response message."""
...

async def shutdown(self):
"""Shutdown the agent and clean up resources."""
pass


class BaseToolUseChatAgent(BaseChatAgent):
"""Base class for a chat agent that can use tools.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,5 +169,9 @@ async def collect_group_chat_messages(
# Wait for the runtime to stop.
await runtime.stop_when_idle()

# Call shutdown on all participants
for participant in self._participants:
await participant.shutdown()

# Return the result.
return TeamRunResult(messages=group_chat_messages)
Loading