[BUG] Memory index appends new entries at bottom but truncates from bottom — newest memories lost first
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?
The auto-memory system appends new entries to the bottom of MEMORY.md, but the file is truncated after 200 lines by cutting from the bottom. This means as the memory index grows, the newest and most recently relevant memories are lost first, while the oldest survive — the opposite of the desired behaviour.
What Should Happen?
Truncation should remove the oldest (least relevant) memories, not the newest. This could be achieved by either:
- Prepending new memory entries at the top of the index, or
- Truncating from the top when the limit is reached
Error Messages/Logs
Steps to Reproduce
- Use Claude Code long enough to accumulate >200 memory entries
- Observe that entries beyond line 200 (the newest) are silently dropped from context
- Older entries from the beginning of the file remain loaded
Claude Model
Not sure / Multiple models
Is this a regression?
No, this never worked
Last Working Version
_No response_
Claude Code Version
2.1.86 (claude code)
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
Claude confirmed during conversation that new entries are appended at the bottom and that the file is truncated after 200 lines. The current behaviour means a long-term user's memory index progressively loses recent context while retaining stale older context.
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗