Agent token TTL too short (~15min) — kills 30-40% of long-running worktree agents

Resolved 💬 3 comments Opened Mar 23, 2026 by jon749 Closed Mar 26, 2026

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 /login 12+ 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

  1. Launch Claude Code with Opus 4.6
  2. Dispatch a background worktree agent with a complex task (e.g., "review 20 files, fix bugs, run tests, commit")
  3. Wait ~15 minutes
  4. 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.

View original on GitHub ↗

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