agentmemory icon indicating copy to clipboard operation
agentmemory copied to clipboard

Feature request: optional `AGENT_ID` scope for multi-agent memory isolation

Open chdlc opened this issue 6 months ago • 2 comments

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:

  • architect
  • developer
  • reviewer
  • researcher
  • support-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 agentId metadata.
  • 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:

  • shared keeps the current cross-agent behavior.
  • isolated only retrieves memories from the same TEAM_ID + USER_ID + AGENT_ID, unless explicitly shared.

Backward compatibility

This should not need to be a breaking change:

  • Existing installs without AGENT_ID keep working as they do today.
  • Existing memories without agentId can 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.

chdlc avatar May 19 '26 21:05 chdlc

I can pick this issue!

neuralmanacle avatar May 24 '26 05:05 neuralmanacle

Fixed in v0.9.22 — https://github.com/rohitg00/agentmemory/releases/tag/v0.9.22. Thanks for the report.

rohitg00 avatar May 26 '26 10:05 rohitg00