Skip to content

Reduce context usage for list_pull_requests#2087

Merged
kerobbi merged 2 commits intomainfrom
kerobbi/reduce-context-list-pull-requests
Feb 25, 2026
Merged

Reduce context usage for list_pull_requests#2087
kerobbi merged 2 commits intomainfrom
kerobbi/reduce-context-list-pull-requests

Conversation

@kerobbi
Copy link
Contributor

@kerobbi kerobbi commented Feb 25, 2026

Summary

Reduces context usage for list_pull_requests by using the existing MinimalPullRequest type.

Fields preserved / dropped

Same as #2017, as it uses the same MinimalPullRequest type introduced there for get_pull_request.

Token Reduction

Measured using a script that makes use of OAI's tiktoken library (o200k_base) at 2 and 100 items. The web version can be found here.

Items Baseline Optimised Reduction
2 11,779 1,657 85.9%
100 657, 272 153,352 76.7%

Why

list_pull_requests was returning raw *github.PullRequest objects with ~40+ fields including nested user objects, API URLs, node IDs, etc.. Most of this is noise not useful for model reasoning.

What changed

  • Wired convertToMinimalPullRequest in list_pull_requests
  • Updated relevant tests

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

Prompts tested (tool changes only)

  • List the last 2 PRs in github/github-mcp-server
  • List the last 100 PRs in github/github-mcp-server

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed
  • Updated (README / docs / examples)

@kerobbi kerobbi changed the title wire MinimalPullRequest into list_pull_requests Reduce context usage for list_pull_requests Feb 25, 2026
@kerobbi kerobbi marked this pull request as ready for review February 25, 2026 13:54
@kerobbi kerobbi requested a review from a team as a code owner February 25, 2026 13:54
Copilot AI review requested due to automatic review settings February 25, 2026 13:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces context usage for the list_pull_requests tool by up to 85.9% (2 items) and 76.7% (100 items) by using the existing MinimalPullRequest type introduced in PR #2017. The change converts the tool output from raw *github.PullRequest objects with 40+ fields to streamlined MinimalPullRequest objects that preserve only essential fields for model reasoning while dropping verbose API metadata and nested objects.

Changes:

  • Converted list_pull_requests output from []*github.PullRequest to []MinimalPullRequest using existing convertToMinimalPullRequest function
  • Updated test assertions to work with non-pointer field values in MinimalPullRequest

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/github/pullrequests.go Added conversion loop to transform PR list to MinimalPullRequest slice before marshaling
pkg/github/pullrequests_test.go Updated assertions to compare non-pointer MinimalPullRequest fields directly instead of dereferencing pointers

Copy link
Contributor

@tommaso-moro tommaso-moro left a comment

Choose a reason for hiding this comment

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

🚀

@kerobbi kerobbi merged commit c1ac64f into main Feb 25, 2026
20 checks passed
@kerobbi kerobbi deleted the kerobbi/reduce-context-list-pull-requests branch February 25, 2026 15:25
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