Repository navigation
Description
Context
A third-party benchmark (harness efficiency, not quality) tested nanocoder 1.29.0 against Pi, OpenCode and Claude Code with the model held constant. Quality was statistically identical across all four harnesses, but nanocoder averaged 37.4 tool calls per task against OpenCode's 16.6, at the same grade. The author's specific criticism was that nanocoder was "re-reading the same files more than any other harness".
That observation is not model behaviour. It is a forced round-trip in read_file.
Problem
source/tools/read-file.tsx:122-160: when read_file is called with no line range on a file longer than FILE_READ_METADATA_THRESHOLD_LINES (300, source/constants.ts:54), it returns zero content. It returns metadata plus an instruction blob telling the model to call again with start_line/end_line.
FILE_READ_CHUNK_SIZE_LINES is 250 (source/constants.ts:56), so reading one 800-line file costs 1 metadata call plus 4 chunk calls, all against the same path.
Compounding this, source/tools/read-file.tsx:137-157 emits copy-paste-ready chunk calls in the response:
[Large file - Choose one approach:]
[2. Progressive read: Read file in chunks (recommended chunk size: 200-300 lines)]
- read_file({path: "...", start_line: 1, end_line: 250})
- read_file({path: "...", start_line: 251, end_line: 500})
... and N more chunks to complete the file
We are not merely permitting the expensive path, we are prompting it with ready-made calls. source/app/prompts/sections/file-editing.md:5 reinforces the same instruction.
Scale
Measured against this repo's own tree: 90 of 439 non-spec source files (20%) exceed 300 lines, and 31 exceed 500. In a larger codebase the hit rate is plausibly higher.
Proposed fix
A read should always return usable content. Truncate with a footer instead of returning nothing:
- Raise
FILE_READ_METADATA_THRESHOLD_LINESsubstantially (1500-2000 lines feels right, open to discussion). - On overflow, return the first N lines of actual content plus
[truncated at line N of M, call read_file with start_line to continue]. - Drop the generated chunk-call examples.
This is strictly better than today. The common case collapses to one call, and the rare genuinely-huge-file case degrades to today's two calls rather than five.
Related
Blocked-adjacent to the markFileSeen bug on the same code path, which stacks a third round-trip on top of this one.
Activity
will-lamerton commentedon Aug 3, 2026
Part of #772.
RealBhupesh commentedon Aug 3, 2026
Hi @will-lamerton, I’d like to take #760. I’ll keep the existing full-content path for normal files, replace the zero-content metadata round-trip for large files with a bounded content preview plus an explicit continuation marker, remove the generated chunk-call boilerplate, and update the focused read_file tests. I’ll preserve the read-before-edit guard and keep the behavior recoverable with ranged reads. I’ll open a focused PR after validating the threshold and output contract against the current test suite.
RealBhupesh commentedon Aug 4, 2026
Implemented in PR #782: #782. Large files now return a bounded 250-line preview with a precise continuation hint instead of an empty metadata-first response, while normal reads, explicit ranges, metadata_only, and read-before-edit behavior remain intact. Focused tests, formatting, lint, and type checks pass locally; GitHub CI is rerunning after a small test-stability follow-up.