[PR #5488] feat: skip line numbers in read tool when not paginating #11428

Closed
opened 2026-02-16 18:16:16 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/5488

State: closed
Merged: No


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)

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/5488 **State:** closed **Merged:** No --- 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)
yindo added the pull-request label 2026-02-16 18:16:16 -05:00
yindo closed this issue 2026-02-16 18:16:16 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#11428