Skip to content

feat(search): add fields filtering to search_repositories and search_commits - #3993

Open
tang-ontheway wants to merge 2 commits into
github:mainfrom
tang-ontheway:feat/search-fields-filter
Open

tang-ontheway wants to merge 2 commits into
github:mainfrom
tang-ontheway:feat/search-fields-filter

Conversation

@tang-ontheway

Copy link
Copy Markdown

Summary

Fixes #3975.

Adds optional fields response filtering to search_repositories and search_commits, matching the existing fields filtering pattern used by search_code, search_issues, search_pull_requests, and list_commits.

Changes

  • pkg/github/minimal_types.go: Add searchRepositoriesItemFieldEnum and searchCommitsItemFieldEnum allow-lists.
  • pkg/github/search_tool_types.go:
    • Add Fields []string to SearchRepositoriesInput and SearchCommitsInput, and normalize/validate fields in normalizeSearchArguments.
    • Add projectSearchRepository and SearchCommitsOutput / structuredSearchCommitsOutput so both legacy text responses and modern structured-content responses return only the requested fields when fields is specified.
  • pkg/github/search.go:
    • Expose fields on search_repositories (both minimal_output: true and minimal_output: false) and search_commits.
    • Apply filterEachField and record fields usage telemetry via recordFieldsUsageFor.
  • pkg/github/fields_filtering_test.go, pkg/github/typed_account_repository_search_test.go, pkg/github/__toolsnaps__/*.snap:
    • Add field filtering and telemetry unit tests for search_repositories and search_commits.
    • Update typed output tests and tool snapshots.

Verification

  • go test ./...: all packages pass (including pkg/github snapshot verification and typed output schema validation).

@tang-ontheway
tang-ontheway requested a review from a team as a code owner December 1, 2026 01:21
Copilot AI adaptive review requested due to automatic review settings December 1, 2026 01:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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)

Comment thread pkg/github/search.go
}
}

recordFieldsUsageFor(ctx, deps, "search_repositories", fullPayload, filtered, len(r))
Comment thread pkg/github/search.go
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,
)
@tang-ontheway

Copy link
Copy Markdown
Author

Ran ./script/generate-docs and committed the updated README.md in 495a78e so docs-check passes cleanly. go test ./pkg/github/... passes.

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.

fields for search_repositories and search_commits

2 participants