feat(strands-memory): add multi-agent support to AgentCoreMemorySessionManager#342
Open
feat(strands-memory): add multi-agent support to AgentCoreMemorySessionManager#342
Conversation
…onManager
Tag every message event with agentId metadata so each agent in a
multi-agent session only retrieves its own messages. The
list_messages() path now filters by agent_id first, with a backward-
compatible fallback for sessions created before this change.
Changes:
- create_message: always attach {agentId: agent_id} metadata to both
conversational and blob events (immediate and batched paths)
- _flush_messages_only: group buffered messages by (session_id,
agent_id) so each agent gets its own batched event with correct
metadata
- list_messages: filter by agentId metadata; fall back to unfiltered
query when the filtered result is empty (backward compat)
- initialize: allow multiple agents per session (info log instead of
warning gate)
Closes #149 (multi-agent portion)
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.
Summary
Adds multi-agent support to
AgentCoreMemorySessionManagerby tagging every message event withagentIdmetadata and filtering on read. This allows multiple agents to share the same session while each only seeing its own messages — no config flags or breaking changes required.Key changes:
create_message(): always attaches{agentId: agent_id}metadata to both conversational and blob events (immediate and batched paths)_flush_messages_only(): groups buffered messages by(session_id, agent_id)so each agent gets its own batched event with correct metadatalist_messages(): filters byagentIdmetadata first; falls back to unfiltered query when the filtered result is empty (backward compat for pre-existing sessions)initialize(): allows multiple agents per session (info log replaces warning gate)Backward compatibility: Sessions created before this change don't have
agentIdon message events. The fallback inlist_messages()handles this by retrying without the filter when the filtered query returns empty.Part of #149 (multi-agent portion). Metadata portion is in #339.
Test plan
TestMultiAgentSupportclass covering: metadata tagging on create, blob path, empty agent_id, list filtering, fallback, initialize multi-agent, batched groupingtest_multi_agent_conversation(two agents, disjoint events),test_multi_agent_with_batching(batching + context manager flush)TESTING.md)