feat(agentchat): add get_thread() to BaseGroupChat (closes #6085)#7684
Open
EvanYao826 wants to merge 1 commit into
Open
feat(agentchat): add get_thread() to BaseGroupChat (closes #6085)#7684EvanYao826 wants to merge 1 commit into
EvanYao826 wants to merge 1 commit into
Conversation
Add a public method to retrieve the current message thread from a group chat team after or during a run. - Add and event types in for the RPC protocol. - Add RPC handler in that returns a shallow copy of the internal message thread. - Add public method on that returns a snapshot of the message thread accumulated during runs. - Track messages in on BaseGroupChat during run_stream, clear on reset. - Add 4 pytest-asyncio tests covering: after-run retrieval, not- initialized error, snapshot isolation, and no-task continuation. Closes microsoft#6085 Signed-off-by: EvanYao826 <2869018789@qq.com>
Author
|
@microsoft-github-policy-service agree |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
Implements the feature requested in #6085: expose the group chat message thread as a public async API on
BaseGroupChat.Changes
_events.py— newGroupChatGetThread/GroupChatThreadResponseRPC message types for the protocol._base_group_chat_manager.py— new@rpchandlerhandle_get_thread()that returns a shallow copy of the internalself._message_thread._base_group_chat.py— newasync def get_thread()onBaseGroupChat:self._threadduringrun_stream, cleared onreset()tests/test_group_chat_get_thread.py— 4 pytest-asyncio tests:test_get_thread_after_run— non-empty snapshot matches TaskResult messagestest_get_thread_not_initialized_raises— RuntimeError before first runtest_get_thread_returns_snapshot— mutating returned list does not affect internal statetest_get_thread_with_no_task— works after run with no initial taskDesign note
Unlike
pause()/resume()which usesend_messageduring an active run,get_thread()must work afterrun()completes. Since the embeddedSingleThreadedAgentRuntimestops processing messages afterstop_when_idle(), a puresend_message-based approach would hang. Instead,BaseGroupChatmaintains its ownself._threadlist populated duringrun_stream, which the manager also populates via the shared output message queue. This keeps the API reliable regardless of runtime lifecycle.Related issue number
Closes #6085
Checks