Skip to content

feat: Add MessageStore base class abstraction for message threads#7570

Closed
Ricardo-M-L wants to merge 1 commit intomicrosoft:mainfrom
Ricardo-M-L:feat/message-store-abstraction
Closed

feat: Add MessageStore base class abstraction for message threads#7570
Ricardo-M-L wants to merge 1 commit intomicrosoft:mainfrom
Ricardo-M-L:feat/message-store-abstraction

Conversation

@Ricardo-M-L
Copy link
Copy Markdown

Summary

Adds a storage abstraction for message_thread in teams, as proposed in #6227.

  • MessageStore abstract base class with standard async CRUD operations (add_messages, get_messages, clear) plus save_state/load_state for persistence
  • InMemoryMessageStore concrete implementation — the default, fully backwards-compatible backend with optional TTL (time-to-live) based message expiration
  • Integration into BaseGroupChatManager and all team implementations (RoundRobin, Selector, Swarm, MagenticOne, GraphFlow) via an optional message_store constructor parameter
  • Backwards compatibility_message_thread remains accessible as a property that delegates to the underlying store; existing subclass code continues to work without changes
  • 20 comprehensive test cases covering ABC contract, CRUD, TTL expiration, state persistence, and custom store implementations

Key design decisions

  1. TTL as a constructor parameterMessageStore(ttl=300) enables 5-minute message expiration; None (default) means no expiry
  2. Zero breaking changes — when no message_store is provided, an InMemoryMessageStore is created automatically, preserving identical behavior to the previous List-based storage
  3. Extensibility — users can implement custom MessageStore subclasses (e.g., Redis, database-backed) by implementing 5 abstract methods

Fixes #6227

Test plan

  • Run pytest python/packages/autogen-agentchat/tests/test_message_store.py — 20 test cases for MessageStore abstraction
  • Run existing team tests to verify backwards compatibility
  • Verify InMemoryMessageStore with TTL correctly prunes expired messages
  • Verify state save/load round-trip works with the new store

🤖 Generated with Claude Code

Add a simple storage abstraction for message_thread in teams, with TTL
policy support as a parameter for message expiration.

- MessageStore abstract base class with standard CRUD operations (add,
  get, clear) plus save_state/load_state for persistence
- InMemoryMessageStore concrete implementation (default, backwards
  compatible) with optional TTL-based message expiration
- Integration into BaseGroupChatManager and all team implementations
  (RoundRobin, Selector, Swarm, MagenticOne, GraphFlow)
- Configurable message store via team constructor parameter
- Comprehensive test suite with 20 test cases

Fixes microsoft#6227
@Ricardo-M-L
Copy link
Copy Markdown
Author

Closing — this feature should have been discussed in an issue first before submitting a large PR. Apologies for the noise.

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.

Add MessageStore base class abstraction for storing message thread in teams

1 participant