Repository navigation
Description
Before submitting
- I searched existing issues and did not find a duplicate (closest: [Bug]: idle nested subagent chains stay in the shell snapshot with omitIdleSubagents #29128, [Bug]: Agents panel shows a resumed delegated child once per task record, all Working #30911, Grok turns held open by stalled background subagents show no waiting state, and steering only supersedes attempts #17159, none cover this).
- I included enough detail to reproduce or investigate the problem.
Area
apps/server (orchestration-v2, ProviderSessionManager / Claude adapter), Agents panel
Summary
Provider-native Claude subagents whose account hit its usage limit stay Working in the Agents panel for hours with a running timer, although their child threads have no run and no activity. t3_thread_interrupt cannot clear them ("no active run"). The parent shows "Waiting on N subagents" the whole time.
What I observed (2026-11-20, read from the live server state)
- Parent Claude thread (account A) started 3 native subagents (
thread:subagent:…, Claude Opus) at 01:41 UTC. - All three child threads' last item is at 02:00:04–02:00:25 UTC; the parent's run failed with a usage-limit error at about 02:00:40, and the thread then continued on another provider/account (
limit-switchcontinuation, feat: continue on another account with usage left when one runs out #28595). - At 08:19 UTC (6h 38m later) the three children were still listed as Working 6h 39m / 6h 38m in the Agents panel. Server state for each child at that moment:
status: idle,latestRunId: null,activeRunId: null,runCount: 0,pendingRequestCount: 0. So nothing on the child can be stopped. - A stop sent to each child (
t3_thread_interrupt) answered "no active run" every time. After the children were then marked settled (08:19), the Agents panel still listed them as Working with the timer running, and the parent still showed "Waiting on 2 subagents". I did not check what the panel's own stop buttons do for these rows.
Likely cause (code reading of current main, not verified at runtime)
hasPendingBackgroundWorkinClaudeAdapterV2.tsreturns true while any entry ofsessionSubagentsByTaskIdhasstatus === "running". A subagent that died on the account's usage limit never reports completion, so that entry stays running.releaseIfStillIdleinProviderSessionManager.tsthen pins the session (DEFAULT_MAX_IDLE_PIN_MS= 4h), and any provider activity on the same session resets that budget (pinnedSinceMs: null). The pin therefore never expires while the thread keeps being used.- The orphan cleanup that would end the records as
interrupted(writeReleasedSubagentEvents→endOrphanedNativeSubagent) only runs when the session is released, so it never fires. - A native subagent child thread has no runs, so stop paths that look for an active run have nothing to interrupt and nothing settles the subagent record.
Expected behavior
- When a run ends with a usage-limit failure, or the thread moves to another account/provider, the native subagents of the abandoned session end as
interrupted(or the stale "running" entries stop pinning the session). - Stopping a subagent whose child thread has no run settles its subagent record instead of answering "no active run".
- The Agents panel stops the timer once the child thread is settled.
Steps to reproduce
Depends on the account hitting its limit while background subagents run:
- Run a Claude thread on an account close to its usage limit and have it start several native subagents.
- Let the account hit the limit while they run (or continue the thread on another account right after).
- Open the Agents panel after a few hours and try to stop the rows (or call
t3_thread_interrupton a child).
I have not reproduced this deterministically, and I have not checked whether the same happens without the account-switch continuation; a manual switch to another account after the failed run should leave the same session state.
Environment
Linux server (remote environment), mobile client, Claude Code provider with several accounts, build based on main plus #28595.
Activity
MikaMcFlurry commentedon Nov 20, 2026
Follow-up from the same thread, measured on the server afterwards:
status: idle, no run, and kept the parent inwaiting("Waiting on 2 subagents").t3_thread_organizesettle) and then the parent worked, butt3_thread_liststill reports the parent aswaitingafterwards, whilet3_thread_readreportscompleted. So the "waiting" state seems to come from the leftover subagent records, which settling does not end.So besides ending these records when the session dies, a settle/close of the parent should not be blocked by, or leave behind, records for runless native subagents.
juliusmarminge commentedon Nov 20, 2026
I tried to reproduce this on the current build and could not.
Commit d151236 (origin/main). Could not run the reporter's scenario live: it needs a first-party Claude account hitting its usage limit, which no VM has. Reproduced the core defect as an adapter-level SDK replay in apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts (the test from open PR #24347, adapted to provide NodeCrypto.layer). It starts parent turn 1, which starts two background subagents (task_started) and completes. Parent turn 2 then fails with an assistant rate_limit error and an api_error result. After that, failed system/task_notification frames arrive for both subagents. On main, after both failed notifications, hasPendingBackgroundWork is still true and the subagent records never end:
vp test run src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts -t "usage limit"fails with 'expected true to equal false'. With #24347's one-line ClaudeAdapterV2.ts change applied, it passes. While that entry stays running, ProviderSessionManager.releaseIfStillIdle keeps the session pinned, so the release-time orphan cleanup (writeReleasedSubagentEvents -> endOrphanedNativeSubagent) never runs. Not verified: the 'no active run' answer from t3_thread_interrupt on a runless subagent child thread, and the Agents panel timer.Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.
MikaMcFlurry commentedon Nov 20, 2026
Thanks for the replay. For completeness, the version: my observation was on a fork build based on upstream
c28c6acaf8(2026-11-12) plus my own branches, which include changes toClaudeAdapterV2.tsand the account switch from #28595. So I can't give you clean upstream steps for the live case.Your SDK replay on
d15123668ealready shows the core on main, though: after the failedtask_notificationframes,hasPendingBackgroundWorkstays true and the session stays pinned, so the orphan cleanup never runs. The two parts you couldn't verify (t3_thread_interruptanswering "no active run" on a runless child, and the Agents panel timer) are what that leftover record looks like from the outside.Since #24347 turns that test green, would it make sense to track this there instead? Next time one of my accounts hits its limit with native subagents running, I'll check whether the records end on a build with #24347 applied and report back on that PR.