macOS: Keychain read timeout under load is cached as logged out for 30s ('Not logged in · Please run /login')

Status Open
Reported on v2.1.296
Maintainer reply None cached
Activity 1 comment · opened Oct 13, 2026

Claude Code 2.1.296 (Agent SDK 0.3.296) on macOS reads its Keychain login with security find-generic-password -w using a hard 2000 ms timeout.

When that read times out in a process with nothing cached, the sync read path caches null as "no credential" for 30 s. The OAuth token getter memoizes that null, and the unusable-token recheck runs at most every 30 s. On a loaded machine, a signed-in user's turns therefore fail locally, without any HTTP request, with Not logged in · Please run /login (assistant error authentication_failed, result terminal_reason api_error) for about 30 s after start. Sending another message after that works normally.

Suggested fixes

  • Treat a timed-out read as transient, the way readAsync returns its READ_FAILED sentinel, rather than as absent.
  • Don't memoize null from a failed read.
  • Or raise or adapt the timeout.

Repro
Put a security script that sleeps more than 2 s first on PATH, then start a session.

View original on GitHub ↗

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