anthropics / anthropics/claude-code

Auto-continue at usage limit never arms when the limit kills only background subagents

Open
#89,263 2 comments 1 reaction 0 assignees View on GitHub
area:agents area:core bug platform:linux
Dominant language
Python
Stars
145k
Forks
23.1k
PR merge metrics
PR metrics pending

Description

**What happened**

Two background agents died with `Agent terminated early due to an API error: You've hit your session limit · resets 12am`. The main thread was idle ("Waiting for 1 background agent to finish") and had no in-flight request. At the reset, nothing resumed — no auto-continue, no "press enter to continue" notice.

**Expected**

Since 2.1.234, auto-continue at usage limit is on by default. I expected the session to pick up after the reset. Instead the work was simply lost until I noticed hours later.

**Why (from the 2.1.241 bundle)**

Arming has exactly one entry point: the main REPL stream handler, on an assistant message with `isApiErrorMessage && error === "rate_limit" && quotaLimits`. The quota-rejected subscriber that handles re-arms also requires an active turn claim and returns early unless the rejection origin is `main_thread`. So a quota rejection that only lands on subagents can never arm — and if the main thread happens to be idle at that moment, the whole episode is silently dropped.

**Why it matters**

For delegation-heavy workflows most tokens are spent in subagents, which is exactly the case the feature doesn't cover. The workaround is to keep a prompt queued so the main thread also takes a rejection, which isn't discoverable.

**Suggestion**

Treat a subagent quota rejection as an arming trigger when the main thread is idle. At minimum, arm the "press enter to continue" (stale) path so the session isn't silently abandoned. Ideally the continuation prompt should also name the agents that were killed mid-work, so the main loop relaunches them rather than guessing at "continue".

Version: 2.1.241 · Linux

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the main REPL stream handler and the quota-rejected subscriber described in the 2.1.241 bundle, then compare rejection handling for the main thread and background subagents. Reproduce a session where only subagents hit the usage limit while the main thread is idle. Done means the session arms an auto-continue or stale prompt instead of silently dropping the rejection.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.