Repository navigation
Description
Resolution note, added 2026-08-09. Resolved via the first of the two options in the Fix section below, not the one the title implies. Commit
638a0ea9clarified the read-before-edit refusal messages indiff_edit,string_replaceandwrite_fileso they state that files over 300 lines need a rangedread_filecall. The metadata path atsource/tools/read-file.tsx:160still returns early without callingmarkFileSeen, and that is deliberate: marking a file seen when the model has only received metadata would defeat the guard and permit a blind edit. Do not "fix" that early return. The remaining round-trip cost is tracked in #760, which is the right place to remove it, by having reads return content in the first place.
Problem
source/tools/read-file.tsx:159 returns the metadata response for large files and exits early, without calling markFileSeen. That call only happens on the content path at source/tools/read-file.tsx:173.
The read-before-edit guard in source/utils/read-tracker.ts is therefore never satisfied by a metadata read. A model that calls read_file on a file over 300 lines, gets metadata, and then tries to edit will be refused and forced to read again.
This stacks an extra round-trip on top of the forced metadata round-trip that read_file already imposes on files over 300 lines.
Reproduction
- Call
read_fileon any file longer than 300 lines with nostart_line/end_line. - Attempt a
string_replaceon that file. - The edit is refused for not having read the file, despite
read_filehaving been called on it.
Fix
Judgement call on which way to resolve it:
- If the metadata response is kept, it should not mark the file seen, because the model genuinely has not seen the contents and a blind edit is exactly what the tracker exists to prevent. In that case the fix is to make the refusal message explicit that a ranged read is required, so the model recovers in one step rather than guessing.
- If the linked
read_filechange lands and reads always return content, this resolves itself, and the early return should mark seen for whatever content was returned.
Worth deciding alongside the parent issue rather than in isolation.
Notes for a first-time contributor
The relevant files are small and self-contained: source/utils/read-tracker.ts is 39 lines and well commented on the intent. Tests live in source/tools/read-file.spec.tsx.
Activity
will-lamerton commentedon Aug 3, 2026
Part of #772.
AryanNandanwar commentedon Aug 3, 2026
Hi Will, I'd like to work on this.
DeepamJha commentedon Aug 4, 2026
Hi @will-lamerton happy to help if this is still open, on the two options: I'd lean toward keeping the metadata response as-is and making the refusal message explicit about needing a ranged read, since marking "seen" on metadata-only would undercut what the tracker's for.
Merge pull request #788 from DeepamJha/fix/read-file-metadata-marks-seen
fix: clarify refusal message when only metadata was read The read-bef…