Glob/grep Tool Max Lines (Limit output of all tools?) #1569

Closed
opened 2026-02-16 17:31:35 -05:00 by yindo · 3 comments
Owner

Originally created by @garrett-hopper on GitHub (Sep 2, 2025).

Originally assigned to: @thdxr on GitHub.

By default, the glob/grep tool should have some kind of safety net to prevent the returned results from blowing the context window. (Limit param passed by LLM, default to something large but reasonable, say 500?) Usually ends up being accidentally including dist/node_modules results from grep, though if it's using rg, those should be excluded by default? 🤔

Originally created by @garrett-hopper on GitHub (Sep 2, 2025). Originally assigned to: @thdxr on GitHub. By default, the glob/grep tool should have some kind of safety net to prevent the returned results from blowing the context window. (Limit param passed by LLM, default to something large but reasonable, say 500?) Usually ends up being accidentally including `dist`/`node_modules` results from grep, though if it's using `rg`, those should be excluded by default? 🤔
yindo closed this issue 2026-02-16 17:31:35 -05:00
Author
Owner

@garrett-hopper commented on GitHub (Sep 2, 2025):

I wonder if it's reasonable for all tools to be clipped to some reasonable (10k?) token limit without explicitly bypassing it. Tools returning huge outputs is almost always accidental/unexpected. Could even buffer the output and make it optionally available through a tool only when requested. (Tool response says output has been clipped with instructions to use another tool with a specific ID to read from the remaining output.)

@garrett-hopper commented on GitHub (Sep 2, 2025): I wonder if it's reasonable for all tools to be clipped to some reasonable (10k?) token limit without explicitly bypassing it. Tools returning huge outputs is almost always accidental/unexpected. Could even buffer the output and make it optionally available through a tool only when requested. (Tool response says output has been clipped with instructions to use another tool with a specific ID to read from the remaining output.)
Author
Owner

@roderik commented on GitHub (Sep 2, 2025):

I have similar issues with codegen-ned files with long lines. a graphql schema in my case. I tried a Pr a few days ago that next to "lines" also tries to limit the amount of tokens. https://github.com/sst/opencode/pull/2328

I do not think the PR is ok though thinking on it some more, as it limits on a percentage of the total context window for a provider (e.g. gemini can take a lot more than claude). However only in the case the tokens are larger than the line limits. But it will never successfully complete a task (what the user cares about) if it fills the 75% of the context window with a single file.

@roderik commented on GitHub (Sep 2, 2025): I have similar issues with codegen-ned files with long lines. a graphql schema in my case. I tried a Pr a few days ago that next to "lines" also tries to limit the amount of tokens. https://github.com/sst/opencode/pull/2328 I do not think the PR is ok though thinking on it some more, as it limits on a percentage of the total context window for a provider (e.g. gemini can take a lot more than claude). However only in the case the tokens are larger than the line limits. But it will never successfully complete a task (what the user cares about) if it fills the 75% of the context window with a single file.
Author
Owner

@rekram1-node commented on GitHub (Dec 27, 2025):

[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

@rekram1-node commented on GitHub (Dec 27, 2025): [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1569