feat(agentchat): add get_thread() method to BaseGroupChat#7320
Open
ayzmkk-rongbi wants to merge 1 commit into
Open
feat(agentchat): add get_thread() method to BaseGroupChat#7320ayzmkk-rongbi wants to merge 1 commit into
ayzmkk-rongbi wants to merge 1 commit into
Conversation
Add support for retrieving the current message thread from group chat teams via a new get_thread() public method. This allows users to access all messages exchanged between participants during or after conversation. Changes: - Add GroupChatGetThread RPC event and GroupChatGetThreadResponse in _events.py - Add handle_get_thread RPC handler in BaseGroupChatManager - Add get_thread() method in BaseGroupChat with embedded runtime support - Add comprehensive tests for both single_threaded and embedded runtimes Closes microsoft#6085 Signed-off-by: ayzmkk-rongbi <73167059+ayzmkk-rongbi@users.noreply.github.com>
Author
|
@microsoft-github-policy-service agree company="Microsoft" |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7320 +/- ##
==========================================
- Coverage 81.22% 81.20% -0.02%
==========================================
Files 244 2 -242
Lines 18512 149 -18363
==========================================
- Hits 15036 121 -14915
+ Misses 3476 28 -3448
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Author
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?
Currently, the message thread is stored internally in
BaseGroupChatManager._message_threadbut is not accessible from the public API. Users need a way to:run_stream()Related Issue(s)
Changes
_events.py: AddedGroupChatGetThreadRPC request event andGroupChatGetThreadResponseresponse model containing the serialized message list._base_group_chat_manager.py:handle_get_thread()RPC handler that returns a copy ofself._message_thread_base_group_chat.py:async def get_thread()method with full documentation and usage exampletest_group_chat_get_thread.py: Added three test cases covering:test_get_thread_after_run: Verifies thread contains correct messages afterrun()test_get_thread_empty_after_reset: Verifies thread is empty afterreset()test_get_thread_not_initialized: VerifiesRuntimeErrorwhen team not initializedAll tests run with both
single_threadedandembeddedruntime modes (6 tests total, all passing).Implementation Details
The implementation follows the existing RPC communication pattern used by
reset(),pause(), andresume():BaseGroupChat.get_thread()sends aGroupChatGetThreadRPC message to the managerBaseGroupChatManager.handle_get_thread()returnsGroupChatGetThreadResponsewith the current_message_threadList[BaseAgentEvent | BaseChatMessage]For embedded runtime support,
get_thread()temporarily starts the runtime if the team is not currently running (same pattern asreset()).Usage Example