Skip to content

feat(agentchat): add get_thread() to retrieve group chat message history#7649

Open
paulxg12 wants to merge 1 commit intomicrosoft:mainfrom
paulxg12:feat/get-thread-method
Open

feat(agentchat): add get_thread() to retrieve group chat message history#7649
paulxg12 wants to merge 1 commit intomicrosoft:mainfrom
paulxg12:feat/get-thread-method

Conversation

@paulxg12
Copy link
Copy Markdown

@paulxg12 paulxg12 commented May 2, 2026

Description

This PR implements the get_thread() method on BaseGroupChat to allow external code to retrieve the current message thread from a group chat without waiting for the team to terminate.

Changes

  • _events.py: Added GroupChatGetThread request and GroupChatThreadResponse models following the existing RPC event pattern.
  • _base_group_chat_manager.py: Implemented handle_get_thread() RPC handler and registered it in sequential_message_types to prevent race conditions.
  • _base_group_chat.py: Added public get_thread() async method with full docstring and usage example.
  • test_group_chat.py: Added comprehensive unit tests covering pre-initialization error, post-run retrieval, and concurrent access during execution.

Motivation

As requested in #6085, this feature enables:

  • Monitoring ongoing conversations in real-time
  • Retrieving message history without blocking on team termination
  • External systems querying the chat state for logging, debugging, or UI updates

Testing

  • All 91 existing tests pass
  • 2 new tests added (4 test cases with single_threaded + embedded modes)
  • pyright type checking: 0 errors
  • ruff lint and format: passed

Add get_thread() method to BaseGroupChat that allows external code to
retrieve the current message thread from a group chat without waiting for
the team to terminate. Useful for monitoring ongoing conversations and
retrieving message history via async RPC.

Fixes microsoft#6085
@paulxg12
Copy link
Copy Markdown
Author

paulxg12 commented May 2, 2026

@microsoft-github-policy-service agree

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