perf(coding-agent): cache grouped search results for skip pagination#3263
Draft
wolfiesch wants to merge 1 commit into
Draft
perf(coding-agent): cache grouped search results for skip pagination#3263wolfiesch wants to merge 1 commit into
wolfiesch wants to merge 1 commit into
Conversation
Plain-filesystem search calls with skip now reuse a short-lived, per-session grouped result cache instead of rerunning native grep for each page. The cache is bypassed for archive, internal-URL, and line-range searches, and is cleared on successful write/delete/rename mutations (including handler-owned internal-URL writes).
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.
What
Add a short-lived, bounded, per-session cache for grouped
searchresults so paginatedskippages reuse the first page's grouped filesystem matches instead of rerunning native grep for each page. Output semantics are unchanged.SearchResultCache(LRU + TTL: 45s, max 8 entries) owned perToolSession.SearchTool.executelooks up the cache only forskip > 0;skip = 0recomputes and refreshes the entry. The cache key encodes the query, scope, options, and missing-path set.invalidateFsScanAfter{Write,Delete,Rename}(now passed the session); handler-owned internal-URL writes callclearSearchResultCachedirectly.Why
Paginating a large plain-filesystem search reran the same expensive native grep + grouping for every page. Later pages now reuse the grouped result until the query changes, the TTL expires, or the session mutates files — avoiding repeated work while preserving correctness.
Testing
bun --cwd=packages/coding-agent test test/tools/search-pagination-cache.test.ts test/tools/search-internal-urls.test.ts test/tools/search-path-lists.test.ts test/tools/multi-search-path.test.ts test/tools/multi-path-missing.test.ts test/tools/search-invalid-regex.test.ts→ 70 pass, 0 failbun --cwd=packages/coding-agent run check→ biome + tsgo passbun checkpasses