Session token expires within minutes when multiple subagents are spawned concurrently

Resolved 💬 7 comments Opened Mar 22, 2026 by nrep Closed Apr 21, 2026

Description

When spawning multiple subagents concurrently using the Agent tool with isolation: \"worktree\", some agents fail immediately with \"Not logged in · Please run /login\" even though the parent session was authenticated moments earlier.

Steps to Reproduce

  1. Start a Claude Code session (authenticated)
  2. Use the Agent tool to spawn 4+ subagents simultaneously with isolation: \"worktree\" and run_in_background: true
  3. Some agents (typically ~50% when spawning 4 at once) fail within seconds with \"Not logged in\"

Expected Behavior

All subagents should inherit/read the valid session credentials from ~/.claude/ without requiring re-authentication.

Actual Behavior

Some agents fail with \"Not logged in · Please run /login\" within seconds of being spawned. Running /login in the parent session fixes it temporarily, but the issue recurs on the next batch of concurrent spawns — sometimes within 5 minutes of the previous login.

Environment

  • Platform: macOS (darwin 25.2.0)
  • Shell: zsh
  • Concurrent agents spawned: 4 at a time
  • Parent session: also running inside a worktree

Hypothesis

Likely a race condition where concurrent subagent processes simultaneously read/write the ~/.claude/ credentials file, causing some to see an invalid/partial auth state.

Impact

Requires frequent manual /login interruptions during parallel agent workflows, which significantly disrupts autonomous multi-agent development pipelines.

View original on GitHub ↗

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