Skip to content

Add fields param to search_code and get_file_contents#2775

Draft
tommaso-moro wants to merge 1 commit into
mainfrom
tommaso-moro-add-fields-param-filtering
Draft

Add fields param to search_code and get_file_contents#2775
tommaso-moro wants to merge 1 commit into
mainfrom
tommaso-moro-add-fields-param-filtering

Conversation

@tommaso-moro

Copy link
Copy Markdown
Contributor

What

Adds an optional fields array 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 the total_count / incomplete_results wrapper. 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 fields is omitted, behavior is unchanged (all fields returned).

How

  • Shared filterFields / filterEachField helpers plus per-tool field enums in minimal_types.go.
  • Filtering is applied at the marshal step; existing IFC labeling is preserved.

Notes

This is an experimental branch for evaluating context reduction via runtime response filtering. It intentionally scopes to just these two tools.

Testing

  • Added unit tests for field filtering on both tools.
  • Updated toolsnaps and regenerated README.
  • script/lint clean; script/test (full race suite) passing.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants