Add fields param to search_code and get_file_contents#2775
Draft
tommaso-moro wants to merge 1 commit into
Draft
Conversation
Add an optional `fields` array parameter to the `search_code` and `get_file_contents` tools so callers can request only the fields they need, reducing tool response size and context usage. - search_code: filters each result item to the selected fields while preserving the total_count / incomplete_results wrapper. - get_file_contents: filters each directory entry when listing a directory; ignored for single-file responses. Adds shared filterFields / filterEachField helpers and per-tool field enums, plus unit tests and regenerated toolsnaps and docs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Adds an optional
fieldsarray parameter to two tools so callers can request only the fields they need, reducing tool response size and context usage:search_code— filters each result item to the selected fields, preserving thetotal_count/incomplete_resultswrapper. Selectable:name,path,sha,repository,text_matches.get_file_contents— filters each directory entry when listing a directory. Ignored for single-file responses. Selectable:type,name,path,size,sha,url,git_url,html_url,download_url.When
fieldsis omitted, behavior is unchanged (all fields returned).How
filterFields/filterEachFieldhelpers plus per-tool field enums inminimal_types.go.Notes
This is an experimental branch for evaluating context reduction via runtime response filtering. It intentionally scopes to just these two tools.
Testing
script/lintclean;script/test(full race suite) passing.