-
Notifications
You must be signed in to change notification settings - Fork 17.5k
Background agents completing in parallel trigger 'Not logged in' and corrupt session credentials #37203
Copy link
Copy link
Open
Labels
area:agentsarea:authbugSomething isn't workingSomething isn't workinghas reproHas detailed reproduction stepsHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOSIssue specifically occurs on macOS
Description
Description
When background agents (launched via the Agent tool with run_in_background: true) complete, the CLI intermittently displays "Not logged in · Please run /login" and the session's auth credentials are permanently lost. The CLI must be fully restarted to recover — /login alone does not fix it.
Reproduction conditions
The error is intermittent and occurs under all of the following conditions:
- Multiple background agents completing simultaneously (2-5 agents finishing within seconds of each other)
- A single background agent completing (only one agent running)
- Multiple Claude Code CLI sessions open simultaneously — however, closing other sessions does NOT fix an already-affected session
- A single Claude Code CLI session with no other sessions running
- Fresh CLI session — sometimes stable for the first few agent completions, then begins failing
- Long-lived CLI session — seems more likely to occur after many agent completion cycles, but also occurs on the first completion in a fresh session
There is no reliable way to prevent it. It appears to be a timing-dependent issue related to auth token state during background agent completion processing.
Reproduction steps
- Start a Claude Code CLI session
- Launch a background agent: any
Agenttool call withrun_in_background: true(e.g., asoftware-implementeragent withisolation: "worktree") - Wait for the agent to complete (typically 2-5 minutes)
- Observe "Not logged in · Please run /login" error on the agent completion notification (intermittent — may take several cycles)
- Once the error occurs, subsequent tool calls or messages fail with auth errors
- CLI must be fully restarted to recover
Impact
- The background agents themselves complete successfully — their work (commits, file changes) is preserved
- Only the parent CLI session's auth state is corrupted
- Requires a full CLI restart after every occurrence, breaking iterative workflows
- In a session dispatching ~12 background agents, the error occurred on roughly half of the completions
Environment
- macOS (Darwin 25.3.0)
- Claude Code CLI (current release as of 2025-03-21)
- Model: claude-opus-4-6
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area:agentsarea:authbugSomething isn't workingSomething isn't workinghas reproHas detailed reproduction stepsHas detailed reproduction stepsplatform:macosIssue specifically occurs on macOSIssue specifically occurs on macOS