Reduce context usage for list_pull_requests#2087
Merged
Conversation
list_pull_requests
Contributor
There was a problem hiding this comment.
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_requestsoutput from[]*github.PullRequestto[]MinimalPullRequestusing existingconvertToMinimalPullRequestfunction - 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 |
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
Reduces context usage for
list_pull_requestsby using the existingMinimalPullRequesttype.Fields preserved / dropped
Same as #2017, as it uses the same
MinimalPullRequesttype introduced there forget_pull_request.Token Reduction
Measured using a script that makes use of OAI's
tiktokenlibrary (o200k_base) at 2 and 100 items. The web version can be found here.Why
list_pull_requestswas returning raw*github.PullRequestobjects with ~40+ fields including nested user objects, API URLs, node IDs, etc.. Most of this is noise not useful for model reasoning.What changed
convertToMinimalPullRequestinlist_pull_requestsMCP impact
Prompts tested (tool changes only)
List the last 2 PRs in github/github-mcp-serverList the last 100 PRs in github/github-mcp-serverSecurity / limits
Tool renaming
deprecated_tool_aliases.goNote: 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
./script/lint./script/testDocs