[BUG] CLI bridge sessions intermittently throw 401 authentication_error on Max plan (v2.1.92)

Resolved 💬 3 comments Opened Apr 6, 2026 by Operatoros23 Closed May 16, 2026

Description

Long-running Claude Code CLI sessions on a Max subscription intermittently fail with:

HTTP 401: authentication_error: invalid x-api-key (request_id: req_011CZmz5WGbwXEAunsNFPjm3)

The error says invalid x-api-key, but we are on Max plan (OAuth) — no API key is configured or expected. The CLI authenticates through the Claude Desktop bridge (bridgeSessionId in session files).

Repro environment

  • Claude Code: 2.1.92 (npm, macOS)
  • Claude Desktop: 1.569.0
  • Plan: Claude Max subscription
  • macOS: Apple Silicon
  • Setup: 8 concurrent CLI sessions running as Discord bots via tmux, each launched with claude --model opus --plugin-dir ...

Repro pattern

Sessions are started via tmux with:

unset CLAUDECODE ANTHROPIC_API_KEY
export DISCORD_BOT_TOKEN=... MCP_CONNECTION_NONBLOCKING=true
claude --model opus --plugin-dir /path/to/discord/plugin

ANTHROPIC_API_KEY is explicitly unset. No API key exists in the environment.

Key observations

| Bot session | Started | Version in memory | 401 errors? |
|-------------|---------|-------------------|-------------|
| closer-bot | Apr 4, 7:00 PM (before update) | Pre-2.1.92 | Never |
| scout-bot | Apr 4, 7:00 PM (before update) | Pre-2.1.92 | Never |
| echo-bot | Apr 5, 4:00 AM (after update) | 2.1.92 | Yes, intermittent |
| jiggy-bot | Apr 5, 4:00 AM (after update) | 2.1.92 | Yes, intermittent |
| claw-bot | Apr 5, various (after update) | 2.1.92 | Yes, intermittent |
| active-bot | Apr 5, 4:00 AM (after update) | 2.1.92 | Yes, intermittent |
| code-bot | Apr 5, 4:03 AM (after update) | 2.1.92 | No (also has a claude-desktop session in same workspace) |

The two sessions started before the 2.1.92 update (still running the old binary in memory) have zero 401 errors over 2+ days. Every session started after the update gets intermittent 401s.

Failure behavior

  • Sessions work normally for hours, then randomly throw 401 on the next API call
  • The error is surfaced to the user (in our case, posted to Discord as a message)
  • Sessions sometimes self-recover after a few minutes; other times they stay broken until manually restarted
  • The bridgeSessionId in the session file appears valid, but the bridge auth fails intermittently

Session file examples

Working (pre-update, no session file created):

# closer-bot PID 14634 — no ~/.claude/sessions/14634.json exists

Broken (post-update):

{"pid":66143,"sessionId":"...","cwd":"/path/to/agent","startedAt":1775376004088,"kind":"interactive","entrypoint":"cli","bridgeSessionId":"session_017LeRdWdZouYQdxWYQMbgLy"}

Expected behavior

CLI sessions on Max plan should maintain stable OAuth authentication through the Claude Desktop bridge without intermittent 401 errors.

Impact

For users running multiple long-lived CLI sessions (automation, bots, agents), this causes unpredictable failures that require manual restarts. The error message referencing x-api-key is misleading since no API key is being used.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗