Repository navigation
fix(tool): enforce the global code search result limit - #1306
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
62e7dd9 to
4273db4
Compare
Scan all git-grep output to count distinct files with text matches instead of stopping at the 101st match, so the truncation note reports the true matched-file count and signals that some files are partially shown or omitted.
|
Pushed a small follow-up commit ( Motivation: with the global limit enforced, a truncated file (or a file omitted entirely beyond the 100-match budget) is indistinguishable from a file that genuinely has that many matches — the caller cannot tell its view is incomplete. Change: instead of breaking at the 101st match, the parse loop now scans all
|
The note was reworded when the global result limit landed (alibaba#1306), but the tools guide and the tool description still quoted the old per-file wording. Describe the per-file max-count 101 probe and the global 100 match cap as they now behave.
Description
Enforce the documented global 100-result limit in
code_search.git grep --max-countlimits matches per file, not across the repository. Previously, two files with 60 matches each produced 120 results even though the response claimed that only the first 100 were shown. Exactly 100 matches also incorrectly triggered the truncation notice.Request one extra match per file to detect overflow, then count only successfully parsed text matches and stop on the 101st. Binary-file diagnostics do not consume the result budget. This keeps the existing output format and file order. It bounds the rendered tool response; it does not introduce a global byte limit or streaming cancellation for the Git subprocess.
Type of Change
How Has This Been Tested?
On macOS arm64 with Go 1.26.8:
make testpasses locally, including race detection.make checkandmake buildpass.make coveragepasses: total statement coverage 91.6% (threshold 90%).git diff --checkpasses; both changed files use LF.ocr review --audience agent --background ...was attempted using the local build, but could not run because no LLM endpoint was configured (resolve LLM endpoint: no valid LLM endpoint configured). No live-model review is claimed.Checklist
go fmt,go vet)AI disclosure
AI assistance: OpenAI Codex was used for investigation, implementation, regression tests, and code review. The exact runtime model identifier has not been independently verified and is not claimed here. No AI attribution trailers are included in the commit.
I have personally reviewed and understood the code, tests, and PR description, and can answer maintainer questions independently. The CLA remains pending.
Related Issues
No existing issue is claimed as resolved. Existing open issues/PRs mentioning
code_search, truncation, and result limits were checked to avoid duplicating an active fix.