Feature request: optional `AGENT_ID` scope for multi-agent memory isolation
Optional AGENT_ID scope for multi-agent memory isolation
Related to #433, but this is a slightly different use case.
#433 seems focused on exposing agent/session identifiers for audit logs and external rate limiting. What I’m looking for is an optional way to use an agent identifier as part of the memory scope itself.
Problem
AgentMemory already supports team/user scoping through TEAM_ID, USER_ID, and TEAM_MODE, but I couldn’t find a documented way to scope memory by agent.
In a multi-agent setup, several agents may run under the same team or user but have very different roles, for example:
architectdeveloperreviewerresearchersupport-agent
Right now, these agents can end up sharing the same memory namespace. That is useful in some cases, but in others it can cause memory pollution between agents with different responsibilities.
For example, it would be useful to model something like:
TEAM_ID=company
USER_ID=engineering-team
AGENT_ID=architect
and:
TEAM_ID=company
USER_ID=engineering-team
AGENT_ID=developer
without having to overload TEAM_ID or USER_ID to represent agent roles.
Proposal
Add an optional agent-level identifier, for example:
AGENT_ID=architect
or:
AGENTMEMORY_AGENT_ID=architect
Possible behavior:
- If unset, AgentMemory keeps the current behavior.
- If set, sessions/observations/memories store
agentIdmetadata. - Recall/search can optionally filter by
agentId. - Audit, viewer, and export data can expose
agentId. - Team/user scoping continues to work as it does today.
A possible model would be:
TEAM_ID = organization / team / workspace
USER_ID = user / team member / service identity
AGENT_ID = agent role / profile / workflow context
Optional isolation mode
This could also support an opt-in mode later, such as:
AGENTMEMORY_AGENT_SCOPE=shared
or:
AGENTMEMORY_AGENT_SCOPE=isolated
Where:
sharedkeeps the current cross-agent behavior.isolatedonly retrieves memories from the sameTEAM_ID + USER_ID + AGENT_ID, unless explicitly shared.
Backward compatibility
This should not need to be a breaking change:
- Existing installs without
AGENT_IDkeep working as they do today. - Existing memories without
agentIdcan remain shared/global inside the current team/user scope. - Agent-level filtering or isolation would be opt-in.
Why
Without an official agent scope, users who need this separation may have to misuse TEAM_ID or USER_ID as agent namespaces.
An optional AGENT_ID would make multi-agent setups cleaner without changing the current default behavior.
I can pick this issue!
Fixed in v0.9.22 — https://github.com/rohitg00/agentmemory/releases/tag/v0.9.22. Thanks for the report.