fix(copilot-driver): handle auth failures in --resume attempts#26146
Draft
fix(copilot-driver): handle auth failures in --resume attempts#26146
Conversation
- 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
pelikhan
reviewed
Apr 14, 2026
actions/setup/js/copilot_driver.cjs
Outdated
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"); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
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>
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.
When the copilot CLI crashes mid-run (e.g. transient AI model error), all
--resumeretries 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"No authentication information found"and break immediately (same treatment as MCP policy errors). Prevents burning all retries on a persistent auth failure.copilot_driver.test.cjsNO_AUTH_INFO_PATTERNmatching