GeezerVison is showing github.com — [CI] Advisor: pass github_token to skip the OIDC app-token exchange by izaitsevfb · Pull Request #192022 · pytorch/pytorch
Conversation
Summary
The Claude CI Advisor is the only Claude workflow in pytorch/pytorch that does not pass github_token: to anthropics/claude-code-action. That omission — not the pinned version — is what makes it the only one hitting the intermittent Workflow validation failed … 401.
At the currently pinned ref (6e2bd528, v1.0.89), src/github/token.ts reads:
export async function setupGitHubToken(): Promise<string> {
const providedToken = process.env.OVERRIDE_GITHUB_TOKEN; // = inputs.github_token
if (providedToken) { return providedToken; } // <- returns BEFORE the exchange
const oidcToken = await retryWithBackoff(() => getOidcToken());
const appToken = await retryWithBackoff(() => exchangeForAppToken(oidcToken, permissions), {...});
}
exchangeForAppToken() POSTs api.anthropic.com/api/github/github-app-token-exchange and is the only call site that can return the 401 carrying that message. Passing github_token never reaches it.
Why this instead of bumping the pin
The alternative under discussion was bumping past upstream anthropics/claude-code-action#1417, which converts that 401 into a graceful warn+skip. But a skipped run still produces no verdict — it trades a visible red for a silent green-empty run, and it's a ~90-version jump on a workflow that uses allowed_bots, use_bedrock, --json-schema, settings, and both the structured_output and execution_file outputs. This change removes the failure class at the current pin with no version-jump risk.
Version currency is a separate question and can be decided on its own merits.
Why pull-requests: read ships in the same patch
With an explicit permissions: block present, unlisted scopes are none. The action's app token carried pull-request read implicitly; the scoped GITHUB_TOKEN does not, and the advisor's investigation prompt runs:
gh pr view ${{ inputs.pr_number }} --repo pytorch/pytorch --json title,body,files
Without the added scope that call would start failing on a private-metadata read, so the two lines belong together.
Prior art
claude-issue-triage-run.yml, claude-distributed-triage.yml, and the gha-infra sibling claude-infra-investigations.yml all already pass github_token. The gha-infra one carries a comment naming this exact mechanism: "it makes the action skip its OIDC app-token exchange, which requires the workflow to match the default branch."
Context
- gha-infra issue: https://github.com/meta-pytorch/pytorch-gha-infra/issues/1320 (closed 2026-07-26; the error string recurred 4× on 2026-07-29/30 with no new issue filed)
- Note the 401 is only part of the current failure mix — the other half is
--json-schema was provided but Claude did not return structured_output, which neither this change nor a version bump addresses. Base rate overall is ~0.73% (162 / 22,274 runs).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
pytorch-bot
Bot
commented
Aug 4, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
🔗 Helpful Links
Note: Links to docs will display an error until the docs builds have been completed.
✅ No Failures
As of commit 1776ad7 with merge base aa8abcb ( ):
💚 Looks good so far! There are no failures yet. 💚
This comment was automatically generated by Dr. CI and updates every 15 minutes.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The Claude CI Advisor is the only Claude workflow in pytorch/pytorch that
does not pass `github_token:` to `anthropics/claude-code-action`. Without
it, `setupGitHubToken()` falls through to `exchangeForAppToken()`, which is
the sole source of the intermittent "Workflow validation failed ..." 401
that has been losing advisor dispatches (see metainternal/pytorch-gha-infra#1320
and its 2026-07-29/30 recurrence). Each lost dispatch leaves an autorevert
suspect commit with no verdict.
Passing `github_token` makes the action return the provided token before it
ever attempts the exchange, removing the failure class at the currently
pinned version rather than chasing a ~90-version bump past the upstream
graceful-skip fix (anthropics/claude-code-action#1417) -- which would only
convert the red into a silent green-empty run, still with no verdict.
`claude-issue-triage-run.yml`, `claude-distributed-triage.yml`, and the
gha-infra `claude-infra-investigations.yml` sibling all already pass it, so
this brings the advisor in line with existing house style.
`pull-requests: read` is required alongside it: with an explicit
`permissions:` block, unlisted scopes are `none`, and the advisor's
investigation prompt runs `gh pr view --json title,body,files`. The action's
app token carried that scope implicitly; the scoped GITHUB_TOKEN does not.
|
PR approved to be merged without human review
Why
Two-line CI plumbing fix in .github/workflows/claude-autorevert-advisor.yml: passing github_token: ${{ secrets.GITHUB_TOKEN }} to claude-code-action (line 58) plus the pull-requests: read scope (line 31) that the prompt's mandatory `gh pr view --json title,body,files` call needs once an explicit permissions block makes unlisted scopes none. The pattern is verified prior art at the identical action pin 6e2bd528/v1.0.89 in claude-issue-triage-run.yml:112 and claude-distributed-triage.yml:116, and the MANDATORY log fetch is unaffected since signal_actions.py:852 builds log_url as a public ossci-raw-job-status S3 URL rather than an Actions API call. Security posture tightens rather than loosens -- the agent trades an app token for a read-only job-scoped token with no write scopes -- and no error handling, validation, or CI gate is removed.
reason: clean
Inference job
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
pytorch-bot[bot] reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Merge started
Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.
Learn more about merging in the wiki.
Questions? Feedback? Please reach out to the PyTorch DevX Team Advanced Debugging
Check the merge workflow status
here
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@claude
Explain in lame terms why this PR makes this workflow use the GH API token budget from the repo, while before it didn't
|
claude[bot] reacted with eyes emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
claude
Bot
commented
Nov 12, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Claude finished @jeanschmidt's task in 34s —— View job
This PR changed which key the workflow uses to call GitHub. Each key has its own rate limit. The new key's limit is shared with every other workflow in the repo, and the old key's limit wasn't.
Plain-language explanation
The analogy
Every call to the GitHub API has to show a key, and each key comes with its own limit on requests per hour.
- Before:
github_token: wasn't set, so claude-code-action got its own key. It sent the job's OIDC token to Anthropic (api.anthropic.com/.../github-app-token-exchange), and Anthropic sent back an installation token for the Claude GitHub App. Every GitHub call the run made went through that app token: gh pr view, and the action's own API calls. GitHub counts an app installation token's requests against that app installation's own limit. That limit is separate from the repo's workflow traffic, so the advisor used none of the repo's GITHUB_TOKEN budget.
- After:
github_token: ${{ secrets.GITHUB_TOKEN }} is set, and the action hands that key straight back (if (providedToken) return providedToken;) without doing the exchange. So every call now uses the repo's own GITHUB_TOKEN. GitHub counts GITHUB_TOKEN requests per repository (1,000/hr by default, higher on Enterprise Cloud), and that one limit is shared by every workflow job in pytorch/pytorch.
In short: the advisor used to pay from the Claude App's own budget, and now it pays from the repo's shared one.
What now counts against the repo budget
- The prompt's
gh pr view ... --json title,body,files (that's also why the PR had to add pull-requests: read).
- Any other
gh or API calls the agent decides to make while investigating.
- The action's own setup calls to GitHub. A later change to this file shows the side effect:
oven-sh/setup-bun asked api.github.com for the Bun tag list on every run, and that request "counts against this workflow's GITHUB_TOKEN API rate limit, and a 403 there fails the advisor run outright" (.github/workflows/claude-autorevert-advisor.yml:44-55). A Bun install step was added to avoid making that call.
Why the change was made anyway
The exchange step was the only place that could produce the intermittent Workflow validation failed 401. Skipping the exchange removed that failure, and the cost is that the advisor now draws on the shared repo limit. Each run makes only a few calls, but when lots of advisor runs happen at once (for example during an autorevert storm) they compete with the rest of CI for the same limit.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|