Skip to content

feat(strands-memory): add multi-agent support to AgentCoreMemorySessionManager#342

Open
tejaskash wants to merge 1 commit intomainfrom
worktree-pr3-multi-agent
Open

feat(strands-memory): add multi-agent support to AgentCoreMemorySessionManager#342
tejaskash wants to merge 1 commit intomainfrom
worktree-pr3-multi-agent

Conversation

@tejaskash
Copy link
Contributor

Summary

Adds multi-agent support to AgentCoreMemorySessionManager by tagging every message event with agentId metadata 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 metadata
  • list_messages(): filters by agentId metadata 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 agentId on message events. The fallback in list_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

  • 11 new unit tests in TestMultiAgentSupport class covering: metadata tagging on create, blob path, empty agent_id, list filtering, fallback, initialize multi-agent, batched grouping
  • All 134 unit tests pass (123 existing + 11 new)
  • Full test suite: 1098 passed, 0 failed
  • 2 new integration tests: test_multi_agent_conversation (two agents, disjoint events), test_multi_agent_with_batching (batching + context manager flush)
  • Integration tests require dev account (see TESTING.md)

…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)
@tejaskash tejaskash requested a review from a team March 14, 2026 03:25
@tejaskash tejaskash deployed to auto-approve March 14, 2026 03:25 — with GitHub Actions Active
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.

1 participant