[BUG] Agent memory writes to unpredictable location (project-level vs global)

Resolved 💬 2 comments Opened Mar 6, 2026 by ThatDragonOverThere Closed Apr 3, 2026

Description

Custom agents with Persistent Agent Memory sections specify an explicit memory directory path (e.g., C:\Users\Username\.claude\agent-memory\my-agent\), but in practice the agent writes its MEMORY.md and topic files to either the project-level .claude/agent-memory/ or the global ~/.claude/agent-memory/ inconsistently.

The same user, same agent definition, same project — invoked the same way every time — produces memory writes at different locations across sessions.

Evidence

Auditing 11 custom agents across both locations:

| Agent | Project-level | Global-level | Issue |
|-------|--------------|-------------|-------|
| bug-reporter | 3,260 bytes | 3,260 bytes (identical) | Duplicate |
| doc-owner | 5,415 bytes | empty dir | Split |
| git-manager | 2,370 bytes | 807 bytes (subset) | Split — different content |
| ram-safety-auditor | 2,839 bytes (stale) | 9,914 bytes (current) | Inverted — global is authoritative |
| vold-analysis | empty dir | 4,355 bytes + 3 topic files | Inverted — global is authoritative |
| news-shock-agent | 4,118 bytes + topic file | empty dir | Split |
| pipeline-orchestrator-5min | 7,328 bytes | empty dir | Split |
| 1min-eod-pipeline-owner | (no dir) | 6,883 bytes + topic file | Global only |
| wiring-auditor | (no dir) | 6,003 bytes | Global only |
| live-ops-monitor | empty dir | (no dir) | Empty at both |

5 agents have their authoritative content at project-level, 4 at global-level, and 2 are duplicated or empty.

Expected Behavior

Agent memory should consistently write to the path specified in the agent definition's Persistent Agent Memory section. If the definition says ~/.claude/agent-memory/agent-name/, it should always write there.

Actual Behavior

Memory writes are non-deterministic between project-level and global-level directories. This causes:

  1. Lost context — agent can't find its own previous memories because they're at the other location
  2. Stale duplicates — same agent has different (conflicting) content at each location
  3. No sync mechanism — nothing merges or reconciles the two copies

Related Issues

  • #10061 — Sub-agents load skills from global directory instead of project directory (same class: global vs project path confusion)
  • #5750 — Global agents invisible in project context
  • #30579 — CLAUDE_CODE_AUTO_MEMORY_PATH undocumented
  • #4588 — Feature request for persistent agent memory
  • #25739 — Feature request for portable project memory

Environment

  • Claude Code v2.1.69
  • Windows 10 (MSYS2/Git Bash)
  • 11 custom agents defined in both <project>/.claude/agents/ and ~/.claude/agents/

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗