Summary
A partial read guard is a safety check in a coding agent's file-writing tool that refuses to overwrite a file unless the agent has actually read everything it is about to replace. The guard records which line ranges were read and compares that coverage against the file's current line count before permitting a write. The point is to prevent the classic agent failure mode: the model sees only part of a file, then writes back a "full" version that silently deletes the part it never saw.
Claude Code v2.1.280 fixed a real instance of this bug class in Cowork session memory files, and it exposes the subtlety that makes the guard hard to get right: the coverage the guard must trust is the range actually displayed to the model, not the range that was requested from the read tool.
Key Points
- Failure shape: an agent reads a file, a layer in between elides the middle, the model writes back head + tail, and the omitted middle is lost.
- Claude Code v2.1.280 (Cowork memory): memory files over ~10,800 characters were shown to Claude as only the start and end; the retried write then dropped the middle of the file. Fixed as a memory write conflict.
- Reference implementation (yoyo, Day 241
partial_read_guard):write_filerefuses an overwrite when recorded reads do not cover the file's current line count;read_filepages at 500 lines so full coverage is achievable in bounded chunks. - Truncation variant: the Claude Code case is the variant where the elision happens in a display/truncation layer rather than in the read tool itself — the model was handed head + tail and wrote back the whole file.
- Latent residue (yoyo #1094, item 2): coverage is recorded inside
TruncatingTool, keyed off the yoagent header; a middle cut performed by yoyo truncation can therefore register as full coverage and satisfy the guard incorrectly. - The rule: any layer that elides the middle of what the model sees — truncation, head/tail summaries, conflict views — must feed the overwrite guard the range actually shown, not the range requested.