[Bug]: A Claude subagent resumed with SendMessage stays "completed" or "failed" in the Agents panel (regression of #5529) #14002
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/web
Steps to reproduce#
- In a Claude thread, have the agent start a background subagent and let it finish (or fail, for example on the session limit).
- Have the main agent continue it with
SendMessage. - Watch the Agents panel while the subagent works.
Expected behavior#
The subagent shows as running again, and completes again when the second run ends.
Actual behavior#
Same symptom as #5529, which was closed on 2026-08-10; it is back on main.
The subagent runs again, but the Agents panel keeps showing it as completed, with the first run's duration. The same happens after a failure: a subagent stopped by the session limit (Agent terminated early due to an API error: You've hit your session limit) and continued after the reset keeps the red error and the failed status for the whole second run, which in my case lasted 1.5 hours.
Cause
Claude Code does not send a task_updated with status: "running" on resume. It sends a second task_started for the same task_id, with the tool_use_id of the SendMessage call. ClaudeAdapter forwards it as task.started with the new toolUseId.
In packages/client-runtime/src/state/subagentRuntime.ts, foldSubagentActivities, the task.started case treats a start that arrives after a terminal status as a late, out-of-order delivery and only fills metadata ("Reactivation comes exclusively from explicit status transitions (task.updated / progress status)"). A following task.progress without an explicit status does not reopen a terminal agent either (the !isTerminalSubagentStatus(agent.status) guard). So the second run never shows as running, and a failed run keeps its error, because the error is cleared only in applyStatus on the terminal → running transition.
Possible fix
Record the toolUseId of the start that opened the current run (the agent state does not keep it today). A task.started whose toolUseId differs from the recorded one is a new run, not a late copy of the first start: apply the terminal → running transition for it (applyStatus(agent, "running", at)), which also clears the previous run's error. A late duplicate of the original start carries the same toolUseId and would still be ignored, which keeps the protection that the current comment describes.
Impact#
Minor bug or occasional failure
Version or commit#
main @ de251fc (code checked); installed 0.0.43-nightly.20260926.2282
Environment#
Desktop app on Linux (NixOS, Wayland, niri); Claude Code 2.1.283, Opus 5.5
Logs or stack traces#
# Claude Code 2.1.283, `claude -p --output-format stream-json`: a subagent resumed with SendMessage
task_started task_id=a85… tool_use_id=toolu_…RhTc (Agent call)
task_updated task_id=a85… patch.status=completed
task_notification task_id=a85… status=completed
task_started task_id=a85… tool_use_id=toolu_…Qe1d (SendMessage call)
task_updated task_id=a85… patch.status=completed
task_notification task_id=a85… status=completed
# The failure case, from the thread's activities in T3 (times UTC)
09:26:33 task.started taskId=aeb… toolUseId=toolu_…mH9mHu (Agent call)
10:11:20 task.updated taskId=aeb… status=failed error="Agent terminated early due to an API error: You've hit your session limit …"
10:11:20 task.completed taskId=aeb… status=failed
11:42:46 task.started taskId=aeb… toolUseId=toolu_…SoG957 (SendMessage call)
13:12:56 task.progress taskId=aeb… lastToolName=Bash (no status)
Screenshots, recordings, or supporting files#
No response
Workaround#
No response
Vantrongs(GitHub profile, opens in a new tab) added labelsbug
Vantrongs(GitHub profile, opens in a new tab) added labelsneeds-triage
juliusmarminge added labelsvia-triage
juliusmarminge removed labelsneeds-triage
Same mechanism, different trigger: a laptop sleep (network loss) rather than a session limit.
T3 Code 0.0.44, macOS desktop, Claude Code with Opus 5.5. Every subagent in flight failed with
ENOTFOUNDwhile the machine slept. On wake, the parent resumed each one withSendMessage. That was 15 subagents across 3 threads. I had two of those threads open in the Agents panel, and all 10 resumed rows there stayed red.One task from
events.<threadId>.log(UTC):23:13:49 task_updated task_id=aecee35… status=failed error="Agent terminated early due to an API error: API Error: Can't reach the API server — check your internet or DNS (ENOTFOUND)" 23:13:49 task_notification task_id=aecee35… status=failed tool_use_id=…2WmhZ4 23:23:44 task_started task_id=aecee35… tool_use_id=…dEaxHt (SendMessage) 23:26:05 task_updated task_id=aecee35… status=completedThere is no
task_updatedwithstatus: "running"between the failure and the resume, so it matches the triage above.@juliusmarminge #14696 is ready for a look. It passed triage, Macroscope approved it, and its CI workflows are waiting for approval because it comes from a fork. It also fixes the stopped row in #14802, which I reproduced live with a model-switch restart; the details are on that issue. Could you approve the workflows and merge it if it looks right?
Note
🤖 GPT-6.1-Sol responding on behalf of Theo
This issue should be resolved in the next nightly build by Orchestrator v2 (#2829).
Please try that nightly. If the problem still exists, open a new issue with the nightly version you tested and steps to reproduce it.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Triage#
Confirmed on
mainatde251fc. The panel behavior matches the stream you captured.ClaudeAdapterforwards eachtask_startedastask.startedwith that call’stoolUseIdand no status. InfoldSubagentActivities(packages/client-runtime/src/state/subagentRuntime.ts), atask.startedthat arrives after a terminal status only fills metadata. It becomesrunningonly whenactivationCount === 0and the status is non-terminal, or when the status isidle. A latertask.progresswith no explicit status does not callapplyStatusonce the agent is terminal.applyStatusclearserror,result, andcompletedAtonly on a terminal →runningtransition, so a session-limit failure stays red for the whole resume, andactivationCountstays1.The duration is
startedAt→completedAt. Both stay pinned to the first run: settled rows inAgentsPanelfreeze atcompletedAt, and a second terminaltask.updated/task.completedis first-write-wins. Usage still max-merges, so the token count can climb on a row that looks finished.The sidebar pill is a different path.
ThreadBackgroundLivenesstreats atask.startedas live again, so the thread can read Working while the panel row stays completed or failed.#5529describes the same symptom and was closed on 2026-08-10 as fixed by#5569. That PR kept row height stable and split usage snapshots off the progress row. The start-after-terminal guard is unchanged since#5219, so this did not regress after a fix; the earlier report was closed against the wrong change. This issue is the live one.#9408tried to fix it by stampingstatus: "running"in the adapter when a settled task is re-registered under a different tool use. It was closed unmerged on 2026-09-19 because provider and orchestration changes are on hold for the V2 rewrite (#2829, still open). The panel does not use a v2 projection yet:ChatViewstill callsfoldSubagentActivitieswith nov2Projection. Desktop wraps that web UI. Mobile does not render this panel.A fold-only change stays on the path users actually hit and does not need an adapter or contract change.
toolUseIdis already on the persistedtask.startedpayload. During the fold, remember everytoolUseIdalready applied to that task. A start whose id is new is a new run:applyStatus(agent, "running", at)clears the previous error, result, andcompletedAtand bumps the run count. A start whose id was already applied is the late duplicate the current comment is protecting against. Remembering the set, rather than only the latest id, matters because a replay of an earlier run’s start can be appended after a newer run. A start with notoolUseIdstays metadata-only, which keeps Codex children and workflow members on the existing path and keeps the late-start tests valid.Impact stays as filed. The agent does run, and the events are stored. Only the panel status, error, run count, and duration are stale.