Repository navigation
feat(github): slim github_list_pr_reviews that never offloads (#357) - #358
Conversation
On busy PRs there was no cheap way to see which bots reviewed which
commit: github_get_pr_details shows only the last 5 reviews, and
github_get_pr_reviews (inline comment bodies) gets offloaded to /tmp,
which mcp__git__-only agents cannot read.
New read-only tool github_list_pr_reviews:
- REST /pulls/{n}/reviews, all pages; fails at MAX_PAGES rather than
returning a partial list.
- One compact row per review: id, author (REST login, [bot] suffix
kept), author_type (User/Bot), state, commit_id, submitted_at. No
bodies or hunks. Null user/login -> "ghost".
- Filters: authors (case-insensitive substrings, blanks ignored),
commit_id (full or >=7-char prefix, case-insensitive).
- include_inline_counts adds per-review inline comment counts via one
paginated /pulls/{n}/comments pass (no extra call when off).
- Compact JSON {pr,total,returned,reviews}.
Never offloaded: new NEVER_OFFLOAD_TOOLS in response_offloader (only
this tool, guarded by a test); _process_result returns its result
without offload or token-limiter truncation. HTTP error text in its
failures is capped at 500 chars.
Registered in registry_github_threads next to
github_list_review_threads, with reviewer/bot/copilot/sourcery
discovery keywords.
Closes #357
Reviewer's GuideData structuresDefine the review-list tool’s input fields and filtering options as the model consumed by its registry entry.
APIExpose the compact PR review listing tool through the GitHub API exports and registry, including its discovery keywords and user-facing tool description.
ImplementationImplement paginated retrieval, compact review rows, author and commit filtering, optional inline-comment counts, and bounded failures for the new listing tool.
Mark the review-list tool as exempt from offloading and bypass both offloading and token truncation when processing its result.
TestsTest the new tool’s compact output, pagination, filters, counts, failures, discovery, and guaranteed inline response behavior.
Verify reviewer, Copilot, and Sourcery search terms discover the new review-list tool.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Linked issuesChecked at commit 26d75f4 #357 feat(github): slim review listing (author/state/commit_id/submitted_at) that never offloads · 7 of 8 met · 1 to check by hand
|
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/mcp_server_git/github/pr_review_list.py" line_range="45" />
<code_context>
+ if len(batch) < _PER_PAGE:
+ return items
+ return fail(
+ f"❌ {what.capitalize()} exceed {MAX_PAGES} pages; refusing to truncate."
+ )
+
</code_context>
<issue_to_address>
**Complete page-limit results fail**
When an endpoint contains exactly `MAX_PAGES * _PER_PAGE` items, `_fetch_pages` reaches `fail` after the final full page without checking whether another page exists, so it reports a complete result as exceeding the limit and callers receive no list.
Check whether another page exists before failing, and return the collected items when the endpoint ends at the page limit.
</issue_to_address>
### Comment 2
<location path="src/mcp_server_git/github/pr_review_list.py" line_range="29-41" />
<code_context>
+) -> list[dict[str, Any]] | ToolFailure:
+ """Every REST page of *endpoint*, or a ready failure."""
+ items: list[dict[str, Any]] = []
+ for page in range(1, MAX_PAGES + 1):
+ response = await client.get(
+ endpoint, params={"per_page": _PER_PAGE, "page": page}
+ )
+ if response.status != 200:
+ error_text = await response.text()
+ if len(error_text) > _MAX_ERROR_CHARS:
+ error_text = error_text[:_MAX_ERROR_CHARS] + "…"
+ return fail(f"❌ Failed to fetch {what}: {response.status} - {error_text}")
+ batch = await response.json()
+ if not isinstance(batch, list):
+ return fail(f"❌ Unexpected response shape from {endpoint}: expected list")
+ items.extend(batch)
+ if len(batch) < _PER_PAGE:
+ return items
</code_context>
<issue_to_address>
**Concurrent deletions skew comment counts**
When a review comment is deleted while `include_inline_counts` is fetching multiple `/comments` pages, the next numbered-page request uses an offset into the changed comment list, so a comment shifted onto an already-read page is skipped; `Counter` then returns an incorrect inline count.
Use a cursor/snapshot-capable listing for the count pass, or detect collection changes and retry it before returning counts.
</issue_to_address>
### Comment 3
<location path="src/mcp_server_git/github/pr_review_list.py" line_range="34" />
<code_context>
+ endpoint, params={"per_page": _PER_PAGE, "page": page}
+ )
+ if response.status != 200:
+ error_text = await response.text()
+ if len(error_text) > _MAX_ERROR_CHARS:
+ error_text = error_text[:_MAX_ERROR_CHARS] + "…"
</code_context>
<issue_to_address>
**Large error bodies consume memory**
When gitHub or a proxy returns a very large non-200 response body, `response.text()` buffers the entire upstream error body before `_MAX_ERROR_CHARS` truncates it, so a proxy or service returning an unusually large error response can consume excessive memory while the tool is handling the failure.
Read only a bounded amount of the error response before constructing the failure message.
</issue_to_address>
### Comment 4
<location path="src/mcp_server_git/github/pr_review_list.py" line_range="30" />
<code_context>
+ """Every REST page of *endpoint*, or a ready failure."""
+ items: list[dict[str, Any]] = []
+ for page in range(1, MAX_PAGES + 1):
+ response = await client.get(
+ endpoint, params={"per_page": _PER_PAGE, "page": page}
+ )
</code_context>
<issue_to_address>
**Slow pages delay the listing**
When gitHub or an intermediary responds slowly across multiple pages, `_fetch_pages` awaits each page sequentially, and the shared client’s `get` uses the session’s default timeout without an overall deadline. A slow GitHub or proxy response can therefore hold a call for minutes per page, with up to 50 pages, so callers wait a long time before receiving a result.
Set a bounded overall deadline for the listing (and return a clear timeout failure) rather than allowing every page to consume the client’s full request timeout.
</issue_to_address>
### Comment 5
<location path="tests/unit/github/test_pr_review_list.py" line_range="106-110" />
<code_context>
+ bot = _review(2, "copilot-pull-request-reviewer[bot]", "Bot")
+ client = FakeClient({_REVIEWS: [_review(1), bot]})
+
+ data = json.loads(await _run(client, authors=["COPILOT"]))
+
+ assert data["total"] == 2
+ assert data["returned"] == 1
+ assert data["reviews"][0]["author"] == "copilot-pull-request-reviewer[bot]"
+ assert data["reviews"][0]["author_type"] == "Bot"
+
</code_context>
<issue_to_address>
**Prefix-only author matching passes**
When an implementation matches authors only with `startswith`, `test_list_pr_reviews_matches_bot_login_when_authors_substring_differs_in_case` uses `"COPILOT"` at the start of the bot login on line 106, so an implementation using `startswith` instead of substring matching still passes its assertions on lines 108–111; callers cannot filter by text appearing later in a login.
Use an author filter that occurs only in the middle of a login and assert that the review is returned.
</issue_to_address>
Summary
Adds a new read-only lean tool,
github_list_pr_reviews. It answers "which bots reviewed, and on which commit" on busy PRs without bodies, diff hunks or offloading./pulls/{n}/reviews, every page. At MAX_PAGES it fails instead of returning a partial list.id,author(REST login,[bot]kept),author_type(User/Bot),state,commit_id,submitted_at. A null user or login is reported asghost.authors(case-insensitive substrings, blank entries ignored) andcommit_id(full SHA or a prefix of at least 7 characters, case-insensitive).include_inline_counts: adds a per-review inline comment count using one paginated/commentspass. When it is off, no extra request is made.NEVER_OFFLOAD_TOOLSinresponse_offloader.pycontains only this tool, and a test enforces that._process_resultskips offload and token-limiter truncation for it. Error bodies in its failures are capped at 500 chars.registry_github_threads.pynext togithub_list_review_threads, with reviewer/bot/copilot/sourcery discovery keywords.Code lives in new small modules. The files that are already over the 500-line limit (
registry_github.py,models.py) were not touched.Testing
pixi run -e quality test): 3522 passed, 0 failed, 7 deselected. Tree/home/memento/ClaudeCode/Servers/git/worktrees/feat-issues-impl, basea8e89e2plus these changes, committed ascb6cf9d.[bot]login matching, User vs Bot, null user and null login, full/short/uppercase commit filtering, short-SHA rejection, inline counts across 2 comment pages, the MAX_PAGES failure, a non-list response, error-text capping, and a 150-row result staying inline while another tool of the same size still offloads.Not yet checked against live ci-framework#476 (all 16 reviews, including Copilot's). That needs the running server reloaded with this branch.
Closes #357
Summary by Sourcery
Add a compact, never-offloaded GitHub PR review listing tool for identifying reviewers and the commits they reviewed.
New Features:
Bug Fixes:
Enhancements:
Tests: