improve search_code query parameter description (fixes #2390)#2442
Open
jluocsa wants to merge 1 commit intogithub:mainfrom
Open
improve search_code query parameter description (fixes #2390)#2442jluocsa wants to merge 1 commit intogithub:mainfrom
jluocsa wants to merge 1 commit intogithub:mainfrom
Conversation
The current `query` description for `search_code` gives the model little useful guidance on GitHub code search syntax, leading to repeated 422 ERROR_TYPE_QUERY_PARSING_FATAL responses from agents that guess at plausible-looking but invalid syntax (e.g. regex without slashes, `filename:` instead of `path:`, `OR` between qualifiers without parentheses). Replace the description with one that explicitly enumerates qualifiers, boolean operators, regex form (slashes), and path globs, plus realistic examples covering each. Updates the search_code toolsnap and README accordingly. Fixes github#2390.
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
Fixes #2390.
The current
queryparameter description for thesearch_codetool gives the model very little useful guidance on GitHub code search syntax, which (per analysis across thousands of agent sessions in #2390) leads to repeated422 ERROR_TYPE_QUERY_PARSING_FATALresponses from agents that guess at plausible-looking but invalid syntax — for example:\"foo\\|bar\"instead of regex/foo|bar/filename:*review*.mdinstead ofpath:*review*.mdpath:docs OR path:.githubwithout parentheses (surprising precedence)This PR replaces the description with one that explicitly enumerates the qualifiers, boolean operators, regex form (slashes), and path globs, plus realistic examples covering each. The new wording is the one suggested by the issue author.
Before
After
Files changed (3 files / 3 lines)
pkg/github/search.go— the description stringpkg/github/__toolsnaps__/search_code.snap— regenerated viaUPDATE_TOOLSNAPS=true go test ./pkg/github -run Test_SearchCodeREADME.md— regenerated viago run ./cmd/github-mcp-server generate-docsValidation
Test_SearchCode(and all subtests) passgo test ./...passes for all 22 packagesNote: I was unable to run
script/lintlocally (nogolangci-lintavailable in my environment) or-race(no CGO toolchain). CI should validate both. Happy to iterate if it surfaces anything.