Skip to content

Make ripgrep match cap configurable via settings.schema.json #13585

@chouzz

Description

@chouzz

What would you like to be added?

packages/core/src/tools/ripGrep.ts hard-codes DEFAULT_TOTAL_MAX_MATCHES = 20000. Every search truncates at that threshold, regardless of repository size. Other tooling that influences context size already exposes knobs in settings.schema.json (e.g., tools.truncateToolOutputThreshold, tools.truncateToolOutputLines). Ripgrep should follow the same pattern so users can tune the limit without patching the CLI.

If you think this can be accept, I can help to implement this.

Why is this needed?

Some users want lower limits to protect context budgets.
We already document and support similar safeguards for shell output truncation, so the configuration pipeline exists all the way from settings.schema.json → CLI config loader → Config → runtime.

In my case, it finds 17000 matches and takes over than 400K context window since it search keywords for ha|HA, most of files in the directory contain such words, and it reach max context window for serval times search, I think it should be configurable.

Additional context

Proposal

  1. Schema
    Add tools.ripgrep.maxMatches (number, default 20000) to schemas/settings.schema.json, with the usual metadata (title, description, markdownDescription, category, restart requirement). Mention it in docs/CLI settings tables so autocomplete works in IDEs.

  2. Config plumbing

    • Update packages/cli/src/config/config.ts to read settings.tools?.ripgrep?.maxMatches (or top-level tools.ripgrepMaxMatches) and pass it into new Config(...).
    • Extend packages/core/src/config/config.ts to store a ripgrepMaxMatches field with fallback to 20000 and a getter.
  3. Runtime usage
    Replace the direct reference to DEFAULT_TOTAL_MAX_MATCHES in RipGrepToolInvocation.execute with const totalMaxMatches = this.config.getRipgrepMaxMatches() (falling back to the default when unset). Keep the constant as a default so tests remain deterministic.

  4. Tests & docs

    • Cover the new getter in config.test.ts.
    • Extend ripgrep tool tests to assert truncation respects the configured value.
    • Document the new setting in docs/cli/settings.md and the VS Code completion schema.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentIssues related to Core Agent, Tools, Memory, Sub-Agents, Hooks, Agent Qualitypriority/p2Important but can be addressed in a future release.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions