You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Edit tools return line-number prefixes while read_file strips them #765
The same file is returned to the model in two different representations depending on which tool produced it.
read_file deliberately strips line numbers (source/tools/read-file.tsx:175-176):
// Return content without line numbers for clean content-based editingreturnlinesToReturn.join('\n');
But string_replace (source/tools/file-ops/string-replace.tsx:86-88) and write_file (source/tools/file-ops/write-file.tsx:58-60) both return it with a %4d: prefix on every line.
Two costs:
The prefix is about 6 characters per line for information the model rarely needs, given both our editors are content-based rather than line-based. On a 500-line file that is roughly 750 tokens of pure formatting.
Seeing the same file in two representations within one session is a plausible independent trigger for re-reading to disambiguate, which is the exact behaviour flagged in the benchmark writeup.
Fix
Drop the prefixes wherever the content is not being cited by line number. Since read_file already establishes the no-line-numbers convention and that is the tool the model sees most, the edit tools should match it.
Related
Largely moot for write_file and string_replace if the echo-removal issues land, since there will be no echoed content left to prefix. Worth keeping open as a convention decision, and it still applies to any future tool that returns file content.
Hey @will-lamerton , I'd like to pick this up. Makes sense to standardize on read_file's no-line-numbers convention ,I'll update string_replace and write_file to drop the %4d: prefix from their returned content so all three tools are consistent. Mind assigning it to me?
Closing this as resolved, and recording the convention it was held open to decide.
The cost argument here died with the bounding work. #776 removed the write_file echo entirely, #784 bounded string_replace to a 20-line window either side of the edit, and #798 has just done the same for diff_edit. No tool returns a whole file to the model any more, so the "roughly 750 tokens on a 500-line file" this issue opened with no longer exists to save. The most any edit tool now emits is about 40 lines of window.
What's left is the convention question, and the answer is that the remaining line numbers stay. Both string_replace and diff_edit now return Updated file context (lines X-Y of N) with [... lines A-B omitted ...] gap markers. The header and the markers cite line numbers, so per-line numbers inside the window are doing orientation work in a partial view that they weren't doing in a full-file dump. Stripping them there would make the excerpt harder to place, not cheaper.
The convention, for future tools returning file content:
read_file returns raw content with no line numbers, for clean content-based editing (source/tools/read-file.tsx:175-176).
Bounded excerpt contexts keep per-line numbers, because their headers and gap markers reference them.
Display formatters always number, and always have. That's the Ink layer, not the LLM payload.
Thanks @Pixie-19 for #790, which correctly identified the inconsistency before the bounding work landed and made the case for dealing with it.
Activity
will-lamerton commentedon Aug 3, 2026
Part of #772.
siddhanttiwari19 commentedon Aug 3, 2026
Hey @will-lamerton , I'd like to pick this up. Makes sense to standardize on read_file's no-line-numbers convention ,I'll update string_replace and write_file to drop the %4d: prefix from their returned content so all three tools are consistent. Mind assigning it to me?
docs(changeset): add release note for Nano-Collective#765
will-lamerton commentedon Aug 9, 2026
Closing this as resolved, and recording the convention it was held open to decide.
The cost argument here died with the bounding work. #776 removed the
write_fileecho entirely, #784 boundedstring_replaceto a 20-line window either side of the edit, and #798 has just done the same fordiff_edit. No tool returns a whole file to the model any more, so the "roughly 750 tokens on a 500-line file" this issue opened with no longer exists to save. The most any edit tool now emits is about 40 lines of window.What's left is the convention question, and the answer is that the remaining line numbers stay. Both
string_replaceanddiff_editnow returnUpdated file context (lines X-Y of N)with[... lines A-B omitted ...]gap markers. The header and the markers cite line numbers, so per-line numbers inside the window are doing orientation work in a partial view that they weren't doing in a full-file dump. Stripping them there would make the excerpt harder to place, not cheaper.The convention, for future tools returning file content:
read_filereturns raw content with no line numbers, for clean content-based editing (source/tools/read-file.tsx:175-176).Thanks @Pixie-19 for #790, which correctly identified the inconsistency before the bounding work landed and made the case for dealing with it.
Document tool output conventions for file content (addresses #765) (#837
feat: add session-scoped artifact lifecycle across CLI and VS Code (#826