Skip to content

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

Closed

Description

@garrett-hopper

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? 🤔

Activity

  1. garrett-hopper commented on Sep 2, 2025

    @garrett-hopper
    Author

    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.)

  2. changed the title [-]Glob/grep Tool Max Lines[/-] [+]Glob/grep Tool Max Lines (Limit output of all tools?)[/+] on Sep 2, 2025
  3. roderik commented on Sep 2, 2025

    @roderik
    Contributor

    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. #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.

  4. rekram1-node commented on Dec 28, 2025

    @rekram1-node
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions