[BUG] A resumed conversation keeps an earlier start's auto-memory path in the system prompt, while the index loads from the current path
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
After a session's auto-memory directory changes, a resumed conversation still names the old directory in the system prompt's memory section, while the same start loads MEMORY.md from the new directory.
The session runs from a subdirectory of a git repo. Its memory directory used to be set by autoMemoryDirectory to the folder keyed by the start directory. The setting was then removed, so memory falls back to the default folder keyed by the git root, and the files were moved there while no session ran. Then the session was started again with claude --continue:
- Instructions block: the session-start
instructionsattachment loads the index from the new folder and lists the old one as removed:
{"type":"instructions","files":[{"path":"~/.claude/projects/<git-root-key>/memory/MEMORY.md","type":"AutoMem",…}],"removed":["~/.claude/projects/<cwd-key>/memory/MEMORY.md"],"changed":true,"reason":"session_start"}
- System prompt, memory section: still names the old folder, which no longer exists:
"You have a persistent file-based memory at ~/.claude/projects/<cwd-key>/memory/. This directory already exists — write to it directly with the Write tool (do not run mkdir or check for its existence)."
So the model is told to write memory files to a folder that the next start does not load. A write there recreates the old folder and splits the memory.
A fresh start from the same directory, with the same settings, names the new folder. Two headless runs from the start directory, with --no-session-persistence, had their system text captured through a local proxy that forwarded each request unchanged:
| Run | Memory sentence names | First line of the system text |
|---|---|---|
| claude -p "<question>" | ~/.claude/projects/<git-root-key>/memory/ | "You are a Claude agent, built on Anthropic's Claude Agent SDK." |
| claude -p --resume <id> --fork-session "<question>" | ~/.claude/projects/<cwd-key>/memory/ | "You are Claude Code, Anthropic's official CLI for Claude." |
The resumed run's system text also carries interactive-only sections (the ! prefix guidance among them) that the fresh -p run lacks, and it matches the live interactive session's prompt. The resumed run therefore reuses a system prompt from an earlier start of the conversation rather than building one for this start. Where that text is kept was not determined: apart from backups of the old settings file, no file under ~/.claude, ~/.cache, ~/.local/state or ~/.config outside the conversation's transcripts names the old folder, and no transcript record holds a system prompt.
What Should Happen?
A resumed conversation's system prompt names the memory directory that start actually loads, as a fresh start's does, so the memory section and the instructions block agree.
Error Messages/Logs
No error is shown. The disagreement is visible only in the request's system text and in the session-start instructions attachment quoted above.
Steps to Reproduce
The layout and order of events in which this was seen:
- A git repo at
<repo>with a subdirectory<repo>/sub. Claude Code always starts in<repo>/sub, so its transcripts go to~/.claude/projects/<cwd-key>/, while the default auto-memory folder is~/.claude/projects/<git-root-key>/memory/. - User settings set
"autoMemoryDirectory": "~/.claude/projects/<cwd-key>/memory"(written as an absolute path). Hold a conversation there over several starts withclaude --continue; memory files accumulate in that folder. - Stop the session. Remove
autoMemoryDirectoryfrom user settings. Move~/.claude/projects/<cwd-key>/memoryto~/.claude/projects/<git-root-key>/memory. - Start again with
claude --continuefrom<repo>/sub. - The session-start
instructionsattachment in the transcript loadsMEMORY.mdfrom<git-root-key>/memoryand lists<cwd-key>/memory/MEMORY.mdas removed. Ask the model to quote the memory sentence of its system prompt: it names<cwd-key>/memory/. - Compare with a fresh
claude -p --no-session-persistencefrom<repo>/sub: its memory sentence names<git-root-key>/memory/.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.296 (Claude Code)
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Other
Additional Information
- Native install, Linux arm64. The interactive session runs inside tmux with
--continue. - Related, different defects: https://github.com/anthropics/claude-code/issues/97722 (
/resumeinside a running session keeps stale CLAUDE.md and memory context;claude --resumereloads them, and here the instructions block was reloaded too, but the system prompt's memory path was not) and https://github.com/anthropics/claude-code/issues/85595 (memory keys on the git root while transcripts key on the start directory, which is why the default folder differs from the old setting here).