Skip to content

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

Closed as duplicate

Description

@jon749

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.

Activity

  1. added
    bug
    has repro
    on Mar 23, 2026
  2. github-actions commented on Mar 23, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. [BUG] Session Token Expiry Kills Active Agents Without Warning #37468
    2. Session token expires within minutes when multiple subagents are spawned concurrently #37324
    3. Background agents completing in parallel trigger 'Not logged in' and corrupt session credentials #37203

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  3. added
    duplicate
    and removed
    bug
    has repro
    on Mar 26, 2026
  4. github-actions commented on Mar 26, 2026

    @github-actions

    This issue has been automatically closed as a duplicate of #37468.

    If this is incorrect, please re-open this issue or create a new one.

    🤖 Generated with Claude Code

  5. github-actions commented on Apr 2, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  6. locked as resolved and limited conversation to collaborators on Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions