Skip to content

Add fields param to six more list/search tools#2810

Open
tommaso-moro wants to merge 1 commit into
tommaso-moro-add-fields-param-filteringfrom
tommaso-moro-add-fields-param-remaining-tools
Open

Add fields param to six more list/search tools#2810
tommaso-moro wants to merge 1 commit into
tommaso-moro-add-fields-param-filteringfrom
tommaso-moro-add-fields-param-remaining-tools

Conversation

@tommaso-moro

@tommaso-moro tommaso-moro commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Note

Stacked on #2775. Review/merge that PR first.

What

#2775 introduced an optional fields response-filtering parameter, gated behind the fields_param feature flag and instrumented with adoption/savings telemetry, for search_code and get_file_contents. This PR extends the exact same pattern to six more read tools:

  • list_issues
  • list_pull_requests
  • list_commits
  • list_releases
  • search_issues
  • search_pull_requests

Callers can pass fields: [...] to receive only the fields they need for each result item, reducing tool response size (and downstream context usage) on the largest, most frequently called read tools.

How

Each tool follows the dual-variant pattern established in the base PR:

  • X — the fields_param-enabled variant. Advertises the fields array parameter, filters each result item to the requested subset, and records telemetry. Owns X_ff_fields_param.snap.
  • LegacyX — the fields_param-disabled variant. Exposes the original schema (no fields), never filters, and records no telemetry — it's the kill switch when the flag is off. Owns the canonical X.snap.

Mutually exclusive FeatureFlagEnable / FeatureFlagDisable annotations guarantee exactly one variant survives inventory filtering for any flag state (asserted for all eight gated tools in Test_FieldsParamVariants_MutuallyExclusive).

Shared helpers keep the surface small:

  • fieldsSchemaProperty builds the fields schema (the base PR's two tools now use it too).
  • recordFieldsUsageFor centralizes the telemetry full-size computation.
  • Filtering reuses the existing filterEachField helper.

Each field enum lists only the JSON fields the specific tool actually emits — e.g. list_commits omits stats/files (it requests commits without per-file detail) and list_issues lists only the fields its GraphQL fragment populates — so callers are never offered a field the tool cannot return.

Testing

  • Per-tool field-filtering, telemetry (filtered savings + unfiltered adoption), and Legacy* definition tests.
  • Extended the mutual-exclusivity gating test to all eight gated tools.
  • Regenerated _ff_fields_param toolsnaps and docs/feature-flags.md.
  • script/lint clean; script/test (race) green.

@Trustinbtc999-hue Trustinbtc999-hue left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Passed

@tommaso-moro tommaso-moro force-pushed the tommaso-moro-add-fields-param-filtering branch from 256394a to a877d9c Compare July 7, 2026 15:08
Extend the optional `fields` response-filtering parameter (gated behind the
`fields_param` feature flag, with adoption/savings telemetry) to six more read
tools, following the dual-variant pattern already used by search_code and
get_file_contents:

- list_issues, list_pull_requests, list_commits, list_releases
- search_issues, search_pull_requests

For each tool, `X` is the flag-enabled variant that advertises `fields` and
filters each result item to the requested subset, while `LegacyX` exposes the
original schema and never filters, acting as a kill switch when the flag is off.
Exactly one variant survives inventory filtering for any flag state via mutually
exclusive FeatureFlagEnable / FeatureFlagDisable annotations. Wrapped responses
(list_issues, search_issues, search_pull_requests) preserve their count /
pagination envelope and only filter the item list; bare-array responses keep
their array shape.

Filtering reuses the shared filterEachField helper. A new fieldsSchemaProperty
helper builds the `fields` schema (search_code and get_file_contents now use it
too), and a shared recordFieldsUsageFor helper centralizes the telemetry
full-size computation. Each field enum lists only the JSON fields the specific
tool actually emits: list_commits omits stats/files (requested without per-file
detail) and list_issues lists only the fields its GraphQL fragment populates.

Adds per-tool field-filtering, telemetry, and Legacy definition tests, extends
the mutual-exclusivity gating test to all eight gated tools, and regenerates the
`_ff_fields_param` toolsnaps and feature-flag docs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tommaso-moro tommaso-moro force-pushed the tommaso-moro-add-fields-param-remaining-tools branch from 66e18ea to 4bbf57c Compare July 8, 2026 12:18

@Trustinbtc999-hue Trustinbtc999-hue left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Add

@tommaso-moro tommaso-moro marked this pull request as ready for review July 9, 2026 10:42
@tommaso-moro tommaso-moro requested a review from a team as a code owner July 9, 2026 10:42
Copilot AI review requested due to automatic review settings July 9, 2026 10:42

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.

Pull request overview

Note

Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.

Extends the feature-flagged fields response-filtering parameter (introduced in #2775) to additional high-traffic read tools to reduce response size and record adoption/savings telemetry.

Changes:

  • Adds dual tool variants (X + LegacyX) for six more list/search tools, gated by fields_param.
  • Implements shared helpers for fields schema/telemetry and applies per-item field filtering across the new tools.
  • Updates toolsnaps, feature-flag docs, and adds/extends tests for gating, filtering, and telemetry.
Show a summary per file
File Description
pkg/github/tools.go Registers new Legacy* tool variants alongside flagged variants.
pkg/github/search_utils.go Adds optional fields filtering + telemetry hook to shared search handler.
pkg/github/search.go Reuses shared fields schema helper and centralizes telemetry sizing logic.
pkg/github/repositories.go Adds fields filtering + telemetry to list_commits / list_releases with legacy variants.
pkg/github/repositories_test.go Updates tool definition assertions/snapshots and checks fields is advertised.
pkg/github/pullrequests.go Adds fields filtering + telemetry to list_pull_requests / search_pull_requests with legacy variants.
pkg/github/pullrequests_test.go Updates tool definition assertions/snapshots and checks fields is advertised.
pkg/github/issues.go Adds fields filtering + telemetry to list_issues / search_issues with legacy variants.
pkg/github/issues_test.go Updates tool definition assertions/snapshots and checks fields is advertised.
pkg/github/minimal_types.go Adds per-tool field enums and a shared fieldsSchemaProperty helper.
pkg/github/fields_telemetry.go Adds recordFieldsUsageFor helper for consistent “full vs sent” sizing.
pkg/github/fields_param_gating_test.go Extends mutual-exclusivity test to all gated tools.
pkg/github/fields_filtering_test.go Adds new tests covering filtering, telemetry, and legacy schemas for new tools.
pkg/github/toolsnaps/*.snap Adds _ff_fields_param snapshots for flagged variants.
docs/feature-flags.md Regenerates automated docs to include fields on newly gated tools.

Review details

  • Files reviewed: 20/20 changed files
  • Comments generated: 2
  • Review effort level: Low

Comment thread pkg/github/fields_telemetry.go
Comment thread pkg/github/issues.go
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.

3 participants