Agent token TTL too short (~15min) — kills 30-40% of long-running worktree agents
Problem
When using Claude Code with background worktree agents for complex multi-file tasks (code review, decomposition, security fixes), agents consistently hit login token expiry after ~15 minutes. The agent returns Not logged in · Please run /login with zero useful work committed.
Impact
In a real-world session tonight (March 22-23, 2026):
- ~140 agents dispatched across 11 bug hunt rounds + 40 evolution tasks
- ~40 agents (~30%) expired before completing their work
- User typed
/login12+ times over ~6 hours - Each expired agent wastes: all tokens consumed, all file reads, all edits — then must be fully re-dispatched
The workaround (re-dispatching) doubles token cost and context waste for every affected agent.
Reproduction
- Launch Claude Code with Opus 4.6
- Dispatch a background worktree agent with a complex task (e.g., "review 20 files, fix bugs, run tests, commit")
- Wait ~15 minutes
- Agent returns:
Not logged in · Please run /login
Tasks that reliably trigger this:
- Security code reviews (read 20+ files, analyze, produce structured report) — ~10-15 min
- Multi-file refactors with build verification (read, edit, xcodebuild/npm test, commit) — ~12-20 min
- Any agent using >50 tool calls
Expected Behavior
- Token TTL of at least 2 hours, OR
- Automatic token refresh mechanism for long-running agents, OR
- Agents inherit the parent session's refresh capability
Environment
- Claude Code v2.1.81
- Model: claude-opus-4-6 (1M context)
- Platform: macOS Darwin 25.2.0
- Agent type: background worktree agents (
isolation: "worktree",run_in_background: true)
Session Evidence
This session shipped 65 commits, 110K+ lines changed, 25 critical security fixes, and 40/40 feature tasks — all while fighting token expiry on every round. The productivity loss from re-dispatching expired agents is substantial and the #1 bottleneck in autonomous multi-agent workflows.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗