[BUG] --remote-control intermittently fails: createCodeSession 401s on attempts 1–2 every launch, only 3 retries, so occasional total failure

Status Closed — duplicate
Reported on v2.1.210
Maintainer reply None cached
Activity 1 comment · opened Jul 17, 2026 · closed Aug 16, 2026

Summary: claude --remote-control intermittently fails at startup with Session creation failed — see debug log. Comparing debug logs from a failing run and a working run shows the remote bridge's createCodeSession returns 401 on the first two attempts on every launch; the retry budget is exactly 3. When the 3rd attempt succeeds, remote control connects; when the 3rd also 401s, it gives up. So this is a retry-budget shortfall against a call that reliably needs more than 2 tries — not a persistent auth problem.

Environment: claude-code 2.1.210 (Homebrew cask), macOS, claude.ai OAuth (Max plan). Launched as claude --name "..." --remote-control. Ordinary inference works throughout (/v1/messages 200s in the same logs) — only the remote-bridge session creation is affected. Empirically this failed ~2 of every 6 launches, independent of --debug/--verbose.

Evidence — failing run:

[code-session] Session create failed 401: Authentication failed
[remote-bridge] createCodeSession failed (attempt 1/3), retrying in 565ms
[code-session] Session create failed 401: Authentication failed
[remote-bridge] createCodeSession failed (attempt 2/3), retrying in 896ms
[code-session] Session create failed 401: Authentication failed          <- attempt 3 also 401
[bridge:repl] handleStateChange state=failed detail="Session creation failed — see debug log"
[bridge:repl] Init returned null (precondition or session creation failed); consecutive failures: 1

Evidence — working run (same machine, same account, minutes apart):

[code-session] Session create failed 401: Authentication failed          <- attempt 1
[remote-bridge] createCodeSession failed (attempt 1/3), retrying in 520ms
[code-session] Session create failed 401: Authentication failed          <- attempt 2
[remote-bridge] createCodeSession failed (attempt 2/3), retrying in 1087ms
[remote-bridge] Created session cse_01Gh...                              <- attempt 3 succeeds
[remote-bridge] Fetched bridge credentials (expires_in=28800s)
[bridge:repl] handleStateChange state=connected

Root cause: attempts 1 and 2 return 401 in both runs — the early 401 is the normal case, not the failure. Success depends entirely on the final (3rd) attempt landing. With only 3 attempts and the first 2 effectively always 401, there is no margin; any run where the 3rd also 401s fails outright.

Requested fixes:

  1. Increase the createCodeSession retry budget and/or backoff so a call that reliably 401s on its first two attempts isn't one flaky attempt away from total failure. Better still: investigate why attempts 1–2 always 401 — it looks like a token/session not-yet-ready condition server-side that a slightly longer wait resolves.
  2. Surface the underlying 401 Authentication failed in the user-facing error. Today it says "Session creation failed — see debug log," but for a plain --remote-control launch no debug log is written unless --debug-file is passed — the referenced log does not exist, and the real cause (401) never reaches the user. (Related: #57258.)

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗