Repeated mid-session logouts on macOS with concurrent instances sharing one Keychain OAuth chain

Status Open
Reported on v2.1.216
Maintainer reply None cached
Activity 1 comment · opened Jul 22, 2026

What happened

The interactive Claude Code session gets logged out repeatedly (multiple times per week, sometimes mid-conversation), requiring /login again. This machine routinely runs many Claude Code instances concurrently (13 claude processes at the time of filing — multi-workspace setups via cmux/Conductor, all as the same macOS user), all sharing the single Keychain item Claude Code-credentials.

This looks like the macOS-Keychain flavor of #76561: that issue isolates (on Linux, with a symlink-shared .credentials.json) a refresh-token rotation race between concurrent instances, where the losers get 401 Invalid authentication credentials and then overwrite the shared credentials with a logged-out stub, killing the human's interactive session too. On macOS there are no symlinks involved — but N concurrent instances still share one OAuth chain through the Keychain, so the same sequence (instance A rotates the refresh token → instance B refreshes with the now-consumed token → 401 → destructive logged-out write) would produce exactly what we observe: recurring hard logouts of the interactive session while background/parallel sessions are running.

Environment

  • Claude Code 2.1.216, macOS 26.5.2 (zsh)
  • Credentials in macOS Keychain (Claude Code-credentials generic password; no ~/.claude/.credentials.json)
  • 13 concurrent claude processes at time of filing (interactive session + cmux/Conductor workspaces), one macOS user, one OAuth chain
  • Keychain item mtime shows a credential write earlier today (20260722053941Z)

Expected

Concurrent instances of one user should converge on the rotated token chain rather than cascade each other (and the interactive session) into logged-out. The mitigations suggested in #76561 apply directly here too:

  1. Re-read the stored credentials immediately before refreshing (another instance may already have persisted a newer chain), and/or lock around refresh+persist.
  2. Don't overwrite the stored credentials with a logged-out stub on a refresh 401 — with concurrent sharers, a transient race becomes a hard logout for everyone.

Repro sketch

Run several long-lived Claude Code instances as one macOS user (e.g. several IDE/terminal workspaces) and keep an interactive session open across access-token expiry boundaries; the interactive session eventually gets logged out without any user action.

View original on GitHub ↗

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