Skip to content

claude harness: a Cloudflare challenge mid-session is treated as a non-retryable first-attempt auth failure #80341

Done

Description

@foolishsailor

What happened

actions/setup/js/claude_harness.cjs treats any authentication failure on the first attempt as non-retryable:

if (attempt === 0 && isAuthenticationFailed) {
  log(`attempt ${attempt + 1}: authentication failed — not retrying (first-attempt auth failure is non-retryable)`);
  return { action: "stop" };
}

We hit a case where that is wrong. Fifteen minutes into a healthy run (45 turns, all API calls succeeding), the Claude CLI emitted a synthetic assistant message and result:

{"type":"assistant","message":{"model":"<synthetic>","content":[{"type":"text","text":"Failed to authenticate. API Error: Just a moment..."}]},"error":"authentication_failed","is_api_error_message":true}
{"is_error":true,"num_turns":45,"terminal_reason":"api_error","api_error_status":403,"result":"Failed to authenticate. API Error: Just a moment...","type":"result"}

"Just a moment..." is the title of a Cloudflare challenge page: the 403 came from the edge, not from the API's credential check, and it is transient. The harness logged:

attempt 1 failed: exitCode=1 ... isRateLimitError=true isAuthenticationFailedError=true ... sessionHasProgress=true ... retriesRemaining=3
attempt 1: authentication failed — not retrying (first-attempt auth failure is non-retryable)

So a run that had already authenticated successfully dozens of times was stopped with three retries unused.

Suggested change

  1. Do not classify an HTML challenge body (Just a moment..., cf-chl, challenge-platform, or generally an HTML document where a JSON error was expected) as authentication_failed; treat it like other transient API errors.
  2. Apply the first-attempt rule only when sessionHasProgress is false. A credential that has worked for the whole session has not become invalid in a way a retry with --continue cannot survive; a genuinely revoked key will fail the retry quickly anyway.

Seen on gh-aw v0.87.5; the same code path is on main today (claude_harness.cjs and AUTHENTICATION_FAILED_PATTERNS in harness_error_patterns.cjs).

Activity

  1. locked and limited conversation to collaborators on Nov 23, 2026
  2. unlocked this conversation on Nov 23, 2026
  3. pelikhan commented on Nov 23, 2026

    @pelikhan
    Collaborator

    @copilot fix for all harnesses

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions