Return closing pull requests from issue_read - #3006
Draft
zwick wants to merge 2 commits into
Draft
Conversation
Answering "is there a PR that closes this issue?" previously required listing pull requests and grepping their bodies for closing keywords, which is expensive and unreliable. GraphQL already exposes Issue.closedByPullRequestsReferences. Add it to the existing issue_read `get` enrichment query so the answer comes back in the same round-trip as the hierarchy signals, as a compact `closed_by_pull_requests` list. An enriched issue with no closing pull requests serializes an explicit empty list so an agent can stop looking. Lockdown mode filters references whose author cannot be verified as safe content, mirroring the existing parent reference handling. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a0b58914-0d94-47a9-8229-c0ef7e32e69f
This enrichment runs on every issue_read get, so embedding up to 25 references costs more than the common case is worth. Embed at most 5, keeping orderByState so open pull requests are the ones that survive. Select totalCount alongside the nodes and return the summary as an object of total_count plus references, so the rare issue with more than five linked pull requests cannot be read as a complete list. The common zero-to-two case stays compact and an empty result stays definitive. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: a0b58914-0d94-47a9-8229-c0ef7e32e69f
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
issue_readwithmethod=getnow returnsclosed_by_pull_requests, a compact summary of the pull requests configured to close the issue, sourced from the GraphQLIssue.closedByPullRequestsReferencesfield.Why
Answering "is there a PR that closes this issue?" previously meant listing up to 100 pull requests and grepping their bodies for closing keywords. That burns a large token budget and misses cross-repo and non-body links. GraphQL already models this relationship directly.
Tracking issue: github/plan-track-agentic-org#192
What changed
closedByPullRequestsReferences(first: 5, includeClosedPrs: true, orderByState: true)withtotalCountto the existingissueReadEnrichmentQuery, so the answer arrives in the same round-trip as the hierarchy signals. No new tool, no extra API call.{ "total_count": N, "references": [...] }. At most 5 references are embedded because this enrichment runs on everyget;total_countis authoritative, so the rare issue with more linked PRs is never read as a complete list. Truncation is derivable fromtotal_count > len(references), so no redundant flag is emitted.MinimalIssue.ClosedByPullRequestsis a pointer: an enriched issue with no closing PRs still serializes a definitivetotal_count: 0, while list/search paths that never enrich omit the key entirely.isSafeParentContentintoisSafeRefContentand reused it to filter closing PR references under lockdown.includeClosedPrsis required because it defaults to false and hides merged and closed PRs, which are exactly what answers "which PR closed this?".orderByStatekeeps open PRs ahead of the cap.MCP impact
issue_readgetgains aclosed_by_pull_requestskey; themethoddescription was updated and the toolsnap regenerated.Prompts tested (tool changes only)
Drove the built server over stdio against the live API:
state: OPEN.state: MERGED, so the retrospective "which PR closed this?" case works.github/github-mcp-server#1— returned PR fix: detect ungraceful stdin close and self-terminate #2325 withstate: CLOSED(unmerged), which the default GraphQL args would have hidden.total_count: 0, references: [].total_count: 7with 5 open references, confirming truncation is visible.Security / limits
Tool renaming
Lint & tests
./script/lint./script/testTable-driven coverage for populated results (including a cross-repo PR), empty results, truncation, title sanitization, lockdown filtering, and the enrichment-failure path.
Docs
script/generate-docs.