opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: skip line numbers in read tool when not paginating

Open remorses opened this issue 1 month ago • 0 comments

Line number prefixes (e.g. 00001| ) are only useful when paginating through a file with offset/limit or when referencing a specific line. For small files that fit within the default 2000 line limit, they waste context.

This change adds line numbers only when:

  • User explicitly passes offset or limit (pagination use case)
  • File is truncated (exceeds limit, so user needs line references to continue reading)

The prefix is 7 characters per line. For a typical file with ~40 char average line length, this saves ~15% tokens per file read. Most files read by the tool are under 2000 lines and don't need pagination, so this reduces context usage for the majority of reads.

Also updated the tool description to reflect this behavior.

Related to #1556 (context window management)

remorses avatar Dec 13 '25 17:12 remorses