fix(grep): grep context blowup from trajectory files#22
Open
Dong1017 wants to merge 1 commit intovigo999:refactor-arch-4from
Open
fix(grep): grep context blowup from trajectory files#22Dong1017 wants to merge 1 commit intovigo999:refactor-arch-4from
Dong1017 wants to merge 1 commit intovigo999:refactor-arch-4from
Conversation
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.
Summary
Fix a
grepfailure mode where broad searches could pull large.cache/*.trajectory.jsonlcontents into tool output and blow up the agent context window.This change keeps the fix minimal and localized to
tools/fs/grep.go.Root Cause
greprecursively searched the workspace without guarding against runtime trajectory files under.cache/.Those files can contain large conversation traces, and
greppreviously returned unbounded matching output, which could flood model context.Changes
.cache/*.trajectory.jsonlduring directory walkgrepstill allows ithead_limitto cap returned match count20100head_limittruncationScope
Intentionally not changed in this PR:
.cacheexclusion beyond*.trajectory.jsonlWhy this approach
This is the smallest fix that addresses the current incident while preserving existing
grepbehavior as much as possible.It blocks the known self-referential trace-file case and adds minimal output guards so
grepcannot return effectively unbounded content.Validation
Ran:
gofmt -w tools/fs/grep.go tools/fs/grep_test.gogo test ./tools/fsgit diff --checkTest result:
ok github.com/vigo999/ms-cli/tools/fsRisk
Low.
The behavior change is limited to:
.cache/*.trajectory.jsonlgrepoutput