Skip to content

[Bug]: A Claude subagent resumed with SendMessage stays "completed" or "failed" in the Agents panel (regression of #5529) #14002

Description

@Vantrongs

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

  1. In a Claude thread, have the agent start a background subagent and let it finish (or fail, for example on the session limit).
  2. Have the main agent continue it with SendMessage.
  3. 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

Activity

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

    bugSomething is broken or behaving incorrectly.via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions