- Notifications
You must be signed in to change notification settings - Fork3.2k
Warn when review comment payload may be truncated#1579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 adds a heuristic warning to theget_review_comments method when the marshaled payload exceeds approximately 8KB. This helps AI agents identify when MCP clients may truncate responses, suggesting they retry with a smallerperPage parameter to avoid missing comments.
Key changes:
- Introduced a threshold constant (8KB) to detect potentially truncated payloads
- Modified the response format to include a warning message when the threshold is exceeded
- Added comprehensive test coverage for the large payload warning scenario
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/github/pullrequests.go | AddedmcpLargePayloadWarningThresholdBytes constant and logic to return a multi-content result (warning + data) when payload size exceeds threshold |
| pkg/github/pullrequests_test.go | Added unit test that creates a large payload scenario and verifies both warning and data content are returned correctly |
Adds a small heuristic warning to
pull_request_read:get_review_commentswhen the marshaled payload is large enough that some MCP clients may truncate it.Motivation: large review comments (big
diff_hunk/bodies) can cause the tool response to be cut off, hiding later comments and confusing agents. The warning suggests retrying with a smallerperPage.Changes:
pkg/github/pullrequests.go: if payload > ~8KB, return a leading WARNING text block plus the JSON.pkg/github/pullrequests_test.go: new unit test covering the warning path.Behavior is unchanged for normal-sized payloads.