Skip to content

[Github Agent] add prFiles and prFailedChecks read actions - #2974

Open
George Ng (GeorgeNgMsft) wants to merge 1 commit into
mainfrom
georgengmsft-github-pr-diagnostics
Open

[Github Agent] add prFiles and prFailedChecks read actions#2974
George Ng (GeorgeNgMsft) wants to merge 1 commit into
mainfrom
georgengmsft-github-pr-diagnostics

Conversation

@GeorgeNgMsft

@GeorgeNgMsft George Ng (GeorgeNgMsft) commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

When a pull request is failing, you usually need two things before you can say anything useful about it: what the PR actually changed, and what the red checks are complaining about. Today the github-cli agent can tell you a PR exists and that its checks are red, but not much more, so answering either question means leaving the agent and running gh by hand.

This adds two read-only actions that answer those two questions directly.

prFiles lists the files a pull request changes, with each file's status and line counts, and optionally a short excerpt of each file's diff.

image

prFailedChecks explains why the checks are red. For each failing check it reports the workflow, timing, and a link, plus the error annotations GitHub recorded against it — usually the actual compiler or test error, with its file and line.

image

Highlights:

  • Deterministic fast actions. Both are typed, read-only, and handled directly: they run gh, parse its JSON, and return a stable rawData payload. No reasoning step is involved, so an external MCP client can discover and call them on its own.
  • Bounded output, honestly labelled. File counts, patch sizes, check counts, and annotation counts all have caps, and every result says explicitly what got truncated instead of quietly dropping it.
  • Diffs are opt-in. When patches aren't requested, they're stripped server-side via --jq, so listing the files of a large PR doesn't download its whole diff.
  • Works on other repos, including by link. Omit repo to use the current checkout, or pass an OWNER/REPO slug — or just the pull request's web link, which gh --repo itself rejects. The host is carried through, so GitHub Enterprise links work too.
  • Degrades instead of failing. Missing logs, in-progress checks, checks from non-GitHub providers, forks, and permission errors each produce a clear partial result and a hint, rather than an error.
  • Natural language too. Grammar rules are added so phrases like "what files did PR 123 change" and "why is PR 123 failing" work, but they're additive — the actions stand on their own.

Tests cover argument construction, JSON parsing and structured results, repo/link normalization, pagination and truncation boundaries, grammar, and the error paths.

@GeorgeNgMsft George Ng (GeorgeNgMsft) changed the title github-cli: add prFiles and prFailedChecks read actions [Github-CLI] add prFiles and prFailedChecks read actions Sep 4, 2026
@GeorgeNgMsft George Ng (GeorgeNgMsft) changed the title [Github-CLI] add prFiles and prFailedChecks read actions [Github Agent] add prFiles and prFailedChecks read actions Sep 4, 2026
@robgruen

robgruen commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

If you're in here adding fun features I would ask you to add "review PR for me" and "investigate PR failure" and variations thereof. (although the latter requires copilot cli).

Image Image

Two read-only actions for diagnosing a pull request without leaving the
agent:

- `prFiles` lists the files a PR changes, with per-file status and line
  counts, and optionally a bounded excerpt of each file's diff.
- `prFailedChecks` explains why a PR's checks are red, pairing each failing
  check with the error annotations GitHub recorded for it.

Both are deterministic fast actions: they shell out to `gh`, parse its JSON,
and return a typed `rawData` payload, so an external MCP client can select
and call them directly with no reasoning step. Output is bounded and every
result states explicitly what was truncated.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
try {
const { stdout, stderr } = await execFileAsync("gh", args, {
timeout: timeoutMs,
maxBuffer: 8 * 1024 * 1024,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a comment here on why we are doing 8MB

number
}
}
| what files does PR $(number:number) change -> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"change", "touch", "edit", "modify"

number
}
}
| show files changed in PR $(number:number) in $(repo:wildcard) -> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"show what's changed in ...."

number
}
}
| why is CI failing on PR $(number:number) -> {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is (the) CI

// patches are large; turn it on to see the actual code changes.
includePatch?: boolean;

// How many files to return, newest API order. 1-300, default 50.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is 50 the default that comes out of the tool itself? If so no need to change...if you want it to be 50 then you could define: maxFiles: number | 50;

@GeorgeNgMsft
George Ng (GeorgeNgMsft) force-pushed the georgengmsft-github-pr-diagnostics branch from 0f46d17 to 2f14903 Compare September 4, 2026 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants