Warn when review comment payload may be truncated#1579
Warn when review comment payload may be truncated#1579AvenJose wants to merge 1 commit intogithub:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a heuristic warning to the get_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 smaller perPage 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 | Added mcpLargePayloadWarningThresholdBytes 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 |
SamMorrowDrums
left a comment
There was a problem hiding this comment.
Testing review comments on fork PRs - this is a brief test for #1749 which fixed a bug where leaving review comments on fork PRs wasn't working.
On the PR itself: This is a nice defensive improvement! Adding warnings for large payloads that may get truncated by MCP clients is helpful for agent debugging. The 8KB threshold seems reasonable, and the test coverage looks good.
SamMorrowDrums
left a comment
There was a problem hiding this comment.
Testing pending review submission on fork PR - verifying fix from #1749
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.