Repository navigation
Bound the output of grep_files - #41
Merged
Merged
Conversation
One grep_files call returned every matching line of every matching file, and the next prompt contains the whole result. On a project with several vendored copies of a dependency, a broad pattern returned more than 1M tokens. The next model call then failed with "prompt is too long". grep_files now stops before 100,000 characters. Its last line then tells how many entries it left out and how to narrow the search. The tool also cuts any matching line that is longer than 500 characters. The tool description tells the agent about both limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
shellygr
marked this pull request as ready for review
November 4, 2026 17:54
jtoman
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
grep_fileshad no limit on its output. Withmatching_lines=True, it returned every matching line of every matching file, and the next prompt contained the whole result. On a project with three vendored copies of OpenZeppelin and four of forge-std (1,274.solfiles, 8.5 MB), one broad pattern added about 1.25M tokens. The next model call then failed withprompt is too long: 1304836 tokens > 1000000 maximum. For example, a grep forfunctionover that tree returns 3.2 MB.Changes:
_grep_implstops adding entries before the output reachesGREP_MAX_OUTPUT_CHARS(100,000 characters). Its last line then tells how many entries it left out, and it tells the agent to use a more specificsearch_stringormatch_in. This applies to both output modes.GREP_MAX_LINE_CHARS(500) is cut and gets a marker. A minified or generated file can hold megabytes on one line._grep_impldocstring now lists its real arguments.Both tool families (
vfs_toolsandfs_tools_layered) share_grep_impl, so both get the limits.Tests:
uv run pytest tests/gives 272 passed, anduv run pyright .gives 0 errors. Without thevfs.pychange, the 4 new tests that check the limits fail.After this merges, AutoProver needs a graphcore pin bump to pick it up.
🤖 Generated with Claude Code