Session token expires within minutes when multiple subagents are spawned concurrently
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
- Start a Claude Code session (authenticated)
- Use the
Agenttool to spawn 4+ subagents simultaneously withisolation: \"worktree\"andrun_in_background: true - 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.
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗