Do not output more than 2000 lines in commands and file reads #1076

Closed
opened 2026-02-16 17:29:24 -05:00 by yindo · 4 comments
Owner

Originally created by @remorses on GitHub (Aug 3, 2025).

Originally assigned to: @thdxr on GitHub.

One of the reasons Claude Code works so well is that it prevents tool calls from eating up all your context window. All tool calls fail if the output size is longer than 2000 lines or 25k tokens. This way the LLM will repeat the commands and file reads to constrain output size, using for example head -n command

Claude Code also uses an LLM to summarize fetch results, adding a field in the fetch tool for the objective of the fetch call

Originally created by @remorses on GitHub (Aug 3, 2025). Originally assigned to: @thdxr on GitHub. One of the reasons Claude Code works so well is that it prevents tool calls from eating up all your context window. All tool calls fail if the output size is longer than 2000 lines or 25k tokens. This way the LLM will repeat the commands and file reads to constrain output size, using for example head -n command Claude Code also uses an LLM to summarize fetch results, adding a field in the fetch tool for the objective of the fetch call
yindo closed this issue 2026-02-16 17:29:24 -05:00
Author
Owner

@thdxr commented on GitHub (Aug 3, 2025):

hm we should be doing this also - is this specifically with the bash tool that it's a problem?

@thdxr commented on GitHub (Aug 3, 2025): hm we should be doing this also - is this specifically with the bash tool that it's a problem?
Author
Owner

@remorses commented on GitHub (Aug 4, 2025):

Yes, bash tool output should be truncated (show last 2000 lines), trying to read a file too long should return an error message, so the LLM can try again and paginate it via line numbers

@remorses commented on GitHub (Aug 4, 2025): Yes, bash tool output should be truncated (show last 2000 lines), trying to read a file too long should return an error message, so the LLM can try again and paginate it via line numbers
Author
Owner

@DiogoDoreto commented on GitHub (Aug 4, 2025):

I've faced this problem too, but in my case with some web searches. Sometimes the model calls the web tool and I've seen my context going straight to 300k tokens when the limit of my model is 128k.

@DiogoDoreto commented on GitHub (Aug 4, 2025): I've faced this problem too, but in my case with some web searches. Sometimes the model calls the web tool and I've seen my context going straight to 300k tokens when the limit of my model is 128k.
Author
Owner

@thdxr commented on GitHub (Aug 12, 2025):

fixed this

@thdxr commented on GitHub (Aug 12, 2025): fixed this
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1076