[BUG] Write tool call reported as successful but file content not persisted when session hits context limit
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?
During a long session that eventually got compacted/summarized, a Write tool call was executed to create a new Java file (TurnstileService.java). The tool returned success and the file appeared in subsequent Read calls within the same session. However, when the session was continued in a new conversation (after context compaction), the file on disk contained only an empty stub — the class declaration with no body.
File appears written during the session (tool returns success, subsequent reads show correct content from cache), but on disk the file is empty or incomplete after compaction.
What Should Happen?
File content written by a successful Write tool call persists to disk regardless of context compaction.
Error Messages/Logs
Steps to Reproduce
- Start a long coding session with multiple file writes
- Let the session reach the context limit and get compacted
- In the resumed session, read a file that was written near the context boundary
- File on disk contains either empty content or only a partial stub
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.63
Platform
Other
Operating System
Windows
Terminal/Shell
PowerShell
Additional Information
The file existed on disk with a valid stub (package declaration + empty @Service class body), suggesting the Write tool was called at least twice — once for the stub and once for the full implementation — and only the first call persisted. The second call (full implementation) returned success within the session context but the content was not on disk when the session was resumed after compaction.
The resumed session's compaction summary described the file as fully implemented, which suggests the tool result was visible to the summarization model but the actual disk write did not complete.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗