| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Reduces token/context usage for pull_request_read’s get_review_comments path by returning a minimized, flattened representation of PR review threads/comments instead of the raw GraphQL-shaped payload.
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/github/pullrequests.go | Switches review-comments response to marshalled minimal response type. |
| pkg/github/minimal_types.go | Adds minimal structs and converters for review threads/comments + pagination. |
| pkg/github/pullrequests_test.go | Updates tests to unmarshal and assert on MinimalReviewThreadsResponse. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes:
Summary
This PR reduces the context window usage when fetching pull request review comments using the pull_request_read tool (get_review_comments).
It does so by using the minimal types pattern (which is already used elsewhere in the codebase for the same reason) to reduce the payload that is sent back to the model when the tool is used. Specifically, GraphQL node IDs are removed, nested author objects are flattened to plain strings, and the Comments.Nodes nesting is flattened to a direct comments array, eliminating unnecessary JSON noise per review thread.
Tests & Metrics
When tested with this PR:
Before: 6815 tokens
After: 5823 tokens
Context reduction: 14.56%
Fields preserved
Thread: is_resolved, is_outdated, is_collapsed, comments, total_count
Comment: body, path, line, author (flattened from Author.Login), created_at, updated_at, html_url (from URL)
Pagination: has_next_page, has_previous_page, start_cursor, end_cursor, total_count
Fields dropped
Thread ID (GraphQL node ID, not used for pagination or any subsequent tool call), Comment ID (GraphQL node ID, not useful for reasoning — html_url is the meaningful identifier)
Why
The raw GraphQL response returned by the GitHub API includes GraphQL node IDs on both threads and comments, deeply nested author objects (Author.Login), and a nested Comments.Nodes array structure that add up across threads and waste context window on every call. These fields are not used by models for reasoning or follow-up tool calls — pagination relies on cursors, and the html_url serves as the useful comment identifier.
What changed
MCP impact
Security / limits
Tool renaming
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
Docs