[BUG] Auto-truncated whole-file Read (PARTIAL view, 2.1.145+) doesn't satisfy read-before-edit guard — Edit fails with "File has not been read yet"

Open 💬 0 comments Opened Jul 2, 2026 by trevor-commits

Summary

Since v2.1.145 — changelog: "Improved the Read tool to return a truncated first page with a 'PARTIAL view' notice instead of a hard error when a whole-file read exceeds the token limit" — a whole-file Read (no offset/limit) of a file that exceeds the ~25k-token page cap returns a partial first page instead of erroring. That partial read does not satisfy the read-before-edit guard, so the next Edit/Write on that same file is rejected with:

File has not been read yet. Read it first before writing to it.

The model did exactly what the guard asks — it issued a full-file Read and received content — but the guard treats an auto-truncated read as "not read." The only recovery is to page through the rest with offset/limit (or re-Read), then retry the edit. Every edit to any file above the cap eats one failed round-trip.

This is a regression introduced by the 2.1.145 change: before it, an oversized whole-file read hard-errored, so there was no ambiguity. Now the read "succeeds" (returns a page) but the edit gate still counts it as unread.

Environment

  • Claude Code CLI 2.1.177 (first observed against the 2.1.145 behavior change; still present)
  • macOS 26.5.1
  • Not model-specific (observed across models); not content-specific — reproduces on any file whose whole-file read exceeds the cap.

Steps to Reproduce

  1. Create/pick a file whose full contents exceed the Read token cap (~25000 tokens in one page). A long Markdown table or any large text file works.
  2. Read(file_path)no offset/limit.
  3. Observe the result is a truncated first page prefixed with:

``
[Truncated: PARTIAL view — showing lines 1-97 of 148 total (32232 tokens, cap 25000). Call Read with offset=98 limit=97 for the next page, or Grep to find a specific section. Do NOT answer from this page alone if the answer may be further in the file.]
``

  1. Edit(file_path, old_string=<a string that IS on the returned first page>, new_string=...).

Observed

Edit fails:

File has not been read yet. Read it first before writing to it.

even though the file was just read in the same turn and the old_string lies within the returned page.

Expected

One of:

  • A partial/auto-truncated whole-file read satisfies the read guard for edits whose old_string falls within the returned range (the model has verifiably seen that text), or
  • the partial-view notice explicitly states the file is not yet considered read for editing and that a full read (paged) is required before Edit — so the misleading "has not been read yet" (it was read) is avoided.

Notes

  • Distinct from #58574 (@-mention synthetic Read injection) and #61404 (NotebookEdit after an explicit offset/limit Read). This case is a whole-file Read with no offset/limit that the tool itself truncated per the 2.1.145 feature — the user/model never asked for a partial read.
  • Workaround: after the partial page, Read the remaining pages via offset/limit, then retry the Edit. It succeeds on the second attempt.
  • Minor: the error text "File has not been read yet" is inaccurate here — the file was read; it was truncated by the tool.

View original on GitHub ↗