Skip to content

fix(copilot-driver): handle auth failures in --resume attempts#26146

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-resume-authentication-issue
Draft

fix(copilot-driver): handle auth failures in --resume attempts#26146
Copilot wants to merge 3 commits intomainfrom
copilot/fix-resume-authentication-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 14, 2026

When the copilot CLI crashes mid-run (e.g. transient AI model error), all --resume retries immediately fail with "No authentication information found" and the driver wastes 3 additional attempts on an unrecoverable error.

Root cause: The auth error message (~404 bytes on stderr) sets hasOutput=true, triggering 3 more retries that all fail identically with the same auth error.

Changes

copilot_driver.cjs

  • Auth error as non-retryable: detect "No authentication information found" and break immediately (same treatment as MCP policy errors). Prevents burning all retries on a persistent auth failure.
[copilot-driver] attempt 2: no authentication information found — not retrying
  (COPILOT_GITHUB_TOKEN, GH_TOKEN, and GITHUB_TOKEN are all absent or invalid)

copilot_driver.test.cjs

  • Tests for NO_AUTH_INFO_PATTERN matching
  • Tests that auth errors block retries at any attempt index (covering the reported bug scenario)

- Add NO_AUTH_INFO_PATTERN to detect 'No authentication information found'
- Auth errors are now non-retryable (like MCP policy errors), preventing
  3 useless retries when COPILOT_GITHUB_TOKEN is absent/invalid
- Add buildSpawnEnv() that falls back to GITHUB_TOKEN then GH_TOKEN when
  COPILOT_GITHUB_TOKEN is absent or empty, fixing auth in AWF mode where
  COPILOT_GITHUB_TOKEN is excluded via --exclude-env
- Log auth token availability (names only, never values) for diagnostics
- Add tests for auth error detection, retry prevention, and fallback logic"

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/9dead9c3-7717-465c-bbd8-027abfb51b7d

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix copilot-driver --resume to handle authentication on retries fix(copilot-driver): handle auth failures in --resume attempts Apr 14, 2026
Copilot AI requested a review from pelikhan April 14, 2026 04:10
Comment on lines +119 to +131
if (!hasTokenValue("COPILOT_GITHUB_TOKEN")) {
if (hasTokenValue("GITHUB_TOKEN")) {
env["COPILOT_GITHUB_TOKEN"] = env["GITHUB_TOKEN"];
log("auth: COPILOT_GITHUB_TOKEN is absent — using GITHUB_TOKEN as fallback");
} else if (hasTokenValue("GH_TOKEN")) {
env["COPILOT_GITHUB_TOKEN"] = env["GH_TOKEN"];
log("auth: COPILOT_GITHUB_TOKEN is absent — using GH_TOKEN as fallback");
} else {
log("auth: warning — COPILOT_GITHUB_TOKEN, GITHUB_TOKEN, and GH_TOKEN are all absent or empty; the copilot CLI may fail to authenticate");
}
} else {
log("auth: COPILOT_GITHUB_TOKEN is set");
}
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.

@copilot this will not help

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed buildSpawnEnv() and the token fallback in bd9d744. You're right — in AWF mode all tokens are absent inside the container (excluded via --exclude-env), and in non-AWF mode COPILOT_GITHUB_TOKEN is always present, so the fallback never has any effect. Kept only the non-retryable auth error detection to stop the useless retry loop.

Remove buildSpawnEnv() and GITHUB_TOKEN/GH_TOKEN fallback logic per
review feedback. The fallback has no effect in AWF mode (all tokens
absent in container) and in non-AWF mode (COPILOT_GITHUB_TOKEN is
always present). Keep the non-retryable auth error detection which
does prevent useless --resume retries on persistent auth failures.

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/cc5b1c53-6d0c-4862-81ff-f4d6d455018a

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
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.

copilot-driver --resume fails with 'No authentication information found' after transient AI model error

2 participants