[BUG] MEMORY.md silently truncated past 200 lines — warning is easy to miss
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?
When ~/.claude/projects/[project]/memory/MEMORY.md exceeds 200 lines, only the first ~200 are loaded into the session. A warning fires at session start ("WARNING: MEMORY.md is N lines (limit: 200). Only part of it was loaded"), but everything past line 200 is silently invisible to the agent for the rest of the session.
side note: I never actually saw the warning, my agent only told me about it when this bug got found.
In practice this means critical memory entries — including ones meant to govern post-compaction behavior — get truncated out without the agent realizing. Repro: any project with a MEMORY.md > 200 lines. The agent reads memory, finds nothing about a topic the user wrote down, and acts as if the memory doesn't exist.
From Claude: "I had a memory entry specifically meant to govern post-compaction behavior. It was at line 238 of a 238-line MEMORY.md. After every compaction, I'd silently revert to behavior that entry was supposed to prevent — because the entry was never in my loaded context. The warning fired once at session start; I either didn't notice it or didn't act, and the rest of the session ran with that memory invisible. Discovered only after my user pointed out I kept making the same mistake."
This also seems to be related to another bug that I've noticed recently, the auto-compaction was not triggering and haulted everything and tried switching to extra usage automatically instead of compacting and continuing. Recently this seems better, this was mainly happening when usingg Sonnet but I am assuming the model should not effect this.
After auto-compacting, I had to remind the agent we already went over this and the outcome we agreed on. Every single compaction. Finally, the agent wrote a note in MEMORY.md explaining this but it got written past line 200, so it got completely ignored until we found this bug.
What Should Happen?
- Auto-trim oldest/least-recent entries beyond the cap
- Hard-fail at session start with a directive to trim before continuing
- Or at minimum, surface the warning directly to the user and prompt a possible trimming
Error Messages/Logs
Steps to Reproduce
- In any Claude Code project, edit
~/.claude/projects/<project-id>/memory/MEMORY.mdso it has more than 200 lines. Add a distinctive marker at the very bottom (e.g., line 250):
- [TEST_MARKER_XYZ](nonexistent.md) — testing truncation
- Start a new Claude Code session in that project's directory.
- Observe the system warning at session start:
"WARNING: MEMORY.md is N lines (limit: 200). Only part of it was loaded."
- Ask Claude: "Do you see TEST_MARKER_XYZ in your memory index? What does it point to?"
Expected: Claude can see the entry and answer.
Actual: Claude does not see it. The entry exists on disk and is referenced from MEMORY.md, but everything past line 200 was truncated out of the loaded context. Claude will either say
it doesn't see the entry or hallucinate a reasonable-sounding pointer.
- Move the same entry to line 5 of MEMORY.md (with no other changes), restart the session, ask the same question.
Expected and actual now match: Claude sees it.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.131 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗