claude-code - 💡(How to fix) Fix [FEATURE] Per-session auto-memory scope alongside global memory (cross-agent leakage in multi-agent workflows) [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#58737Fetched 2026-05-14 03:40:45
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×3commented ×1
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing requests and this feature hasn't been requested yet
  • This is a single feature request (not multiple features)

Problem Statement

Claude Code's auto-memory currently has one scope per git repository: every session launched inside that repo reads and writes the same MEMORY.md index at ~/.claude/projects/<encoded-git-root>/memory/. This works for genuine user-level facts but creates cross-agent leakage in multi-agent and multi-session workflows.

In a multi-agent workflow where several Claude Code sessions run concurrently inside one git repo — each session embodying a different "agent" doing unrelated work — a memory entry written by Agent A (e.g., "user is currently debugging issue X in module Y") becomes visible to Agent B in a different session, even though A's and B's work are unrelated.

This has been observed in practice: agents pick up context from other agents' sessions that they shouldn't have, polluting their reasoning and occasionally producing confused behavior.

The current design assumes one user / one workspace / one stream of work per repo. That assumption breaks for:

  • Operators running multiple Claude Code sessions in tmux panes / IDE windows on different lanes of work in the same repo
  • Multi-agent orchestration where each agent has a distinct identity and lane
  • Worktree-based parallel workflows where each worktree should have its own memory
  • Any pattern where the "agent" or "session" is the appropriate scope, not "the repo"

(Note: this is distinct from #48416, which requests user-scope as a complement to project-scope — a different direction along the same axis. This request is for going narrower than project, not wider.)

Proposed Solution

Requesting: a per-session (or per-cwd, or per-agent-identity) memory scope as a complement to the existing global scope.

Proposed two-tier model

  • Global memory (current behavior): user-level, cross-session, cross-agent — kept for genuine user facts (preferences, identity, durable context).
  • Session memory (new): scoped to a session — persists across context clears within that session, but does not leak to other sessions or other agents.

Possible scope keys (any one would help, ordered by increasing precision):

  1. cwd (so different subdirectories of a repo have separate memory)
  2. session id / Claude Code process id (so even same-cwd concurrent sessions are isolated)
  3. agent identity (declared via env var, frontmatter, or --agent-name flag) — most flexible for orchestration setups

Alternative Solutions

No response

Priority

Medium - Would be very helpful

Feature Category

Configuration and settings

Use Case Example

The submitting operator runs ~30 artificial-person Claude Code agents concurrently inside a single git repository, each with a distinct identity and working directory. They have observed agents picking up context written by other agents — a contamination pattern the current single-scope memory makes inevitable.

A per-session/per-agent memory scope would let each agent accumulate local context (debugging state, ongoing TODOs, partial reasoning) without polluting the global memory or leaking into other agents' contexts. Global memory would remain for the small set of genuinely user-level facts.

Additional Context

Related issues

  • #48416 — user-scope memory (orthogonal, requesting wider-than-project scope)
  • #41283 — memory identity derived from filesystem path
  • #28276 — configurable memory storage location
  • #23544 — ability to disable auto-memory
  • #24044 — MEMORY.md double-load

Submitted via Claude Code on the operator's behalf.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [FEATURE] Per-session auto-memory scope alongside global memory (cross-agent leakage in multi-agent workflows) [1 comments, 2 participants]