Repository navigation
feat(search): add fields filtering to search_repositories and search_commits - #3993
Open
tang-ontheway wants to merge 2 commits into
Open
tang-ontheway wants to merge 2 commits into
tang-ontheway wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Field-filtering telemetry uses the wrong response representation and overstates savings, while missing fields entries in the generated README will cause the documentation check to fail.
2 open issues
What changed in this PR
Adds optional fields filtering to repository and commit searches, extending the existing search-tool pattern to reduce response size and address #3975.
Changes:
- Adds selectable field lists, input validation, and filtering for text and structured responses.
- Records field-filtering usage and response-size telemetry.
- Updates filtering tests, typed-output expectations, and tool schema snapshots.
| File | Description |
|---|---|
pkg/github/typed_account_repository_search_test.go |
Updates typed-output checks for filtered results. |
pkg/github/search.go |
Exposes fields, filters results, and records telemetry. |
pkg/github/search_tool_types.go |
Adds filtering inputs and typed response projections. |
pkg/github/minimal_types.go |
Defines selectable repository and commit fields. |
pkg/github/fields_filtering_test.go |
Adds filtering and telemetry tests for both tools. |
pkg/github/__toolsnaps__/search_repositories.snap |
Updates repository search input and output schemas. |
pkg/github/__toolsnaps__/search_commits.snap |
Updates commit search input and output schemas. |
Review effort: Balanced (adaptive)
| } | ||
| } | ||
|
|
||
| recordFieldsUsageFor(ctx, deps, "search_repositories", fullPayload, filtered, len(r)) |
Comment on lines
+49
to
+52
| schema.Properties["fields"] = fieldsSchemaProperty( | ||
| "Subset of fields to return for each repository search result. If omitted, all fields are returned. Use this to reduce response size when you only need specific fields (e.g. 'full_name', 'html_url', 'language').", | ||
| searchRepositoriesItemFieldEnum, | ||
| ) |
… fields parameter
Author
|
Ran |
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 #3975.
Adds optional
fieldsresponse filtering tosearch_repositoriesandsearch_commits, matching the existingfieldsfiltering pattern used bysearch_code,search_issues,search_pull_requests, andlist_commits.Changes
pkg/github/minimal_types.go: AddsearchRepositoriesItemFieldEnumandsearchCommitsItemFieldEnumallow-lists.pkg/github/search_tool_types.go:Fields []stringtoSearchRepositoriesInputandSearchCommitsInput, and normalize/validatefieldsinnormalizeSearchArguments.projectSearchRepositoryandSearchCommitsOutput/structuredSearchCommitsOutputso both legacy text responses and modern structured-content responses return only the requested fields whenfieldsis specified.pkg/github/search.go:fieldsonsearch_repositories(bothminimal_output: trueandminimal_output: false) andsearch_commits.filterEachFieldand record fields usage telemetry viarecordFieldsUsageFor.pkg/github/fields_filtering_test.go,pkg/github/typed_account_repository_search_test.go,pkg/github/__toolsnaps__/*.snap:search_repositoriesandsearch_commits.Verification
go test ./...: all packages pass (includingpkg/githubsnapshot verification and typed output schema validation).