Skip to content

Agent host: a subagent's tool call is never executed and its turn is never closed, so the chat spins forever #333931

Open

Agent suggestions

Public preview

Description

@RyanEwen

In a dev container, a subagent's tool call is announced and then never executed. Nothing runs it, nothing fails it, and nothing times out, so the subagent's turn stays open and the chat spins indefinitely.

I reproduced this six times, on both a patched and a completely stock build, driving a real window through a scripted scenario rather than by hand.

What happens

A prompt that launches a subagent (Agent / Task) produces, on the subagent's own chat channel:

chat/toolCallStart      turn=3fcf1cc0-…   Bash
chat/toolCallReady      turn=3fcf1cc0-…
                        (nothing further, ever)

At that point, measured inside the container:

  • No process is executing. ps shows no shell, no find, no grep, nothing but the container's own keep-alive processes.
  • The agent host log is silent. Its last line is the tool completion that preceded the hang.
  • The UI still reports the turn as running, and did so for the full 10 minute observation window.
  • The parent's spawning Agent tool call also never completes.

So the call is announced to the client, never executed by anything, and never reaped.

It scales with the number of subagents

A prompt that spawns several subagents leaves several turns open. One run, driven the same way:

chat/turnStarted   x10
chat/turnComplete  x4

Seven subagent turns were opened and two completed; five were left open, along with the parent's follow-up turn. The chat shows nothing further for any of them and no amount of waiting changes it.

That ratio matches what #332073 reports from a different trigger, which is why I think the missing terminal path is worth treating as its own defect rather than only as a consequence of whatever stalls the tool call.

Why the turn never closes

AgentSideEffects.completeSubagentSession is the only thing that completes a subagent chat's turn, and it is reachable from exactly one place: a subagent_completed signal.

node/agentSideEffects.ts
  590:  if (signal.kind === 'subagent_completed') {
  591:      this.completeSubagentSession(signal.chat.toString(), signal.toolCallId);

That signal has two producers, and both are downstream of the spawning tool finishing:

  • claudeMapSessionEvents.ts:406 fires it on the tool_result for the spawning Task/Agent tool_use, and only when the spawn is not flagged background.
  • claudeSubagentSignals.ts:129 fires it on a task_notification with a terminal status.

Because the spawning tool call never completes, neither producer fires. subagent_completed was emitted zero times in every run. The subagent turn is therefore never completed, cancelled or errored.

Nothing else closes it. The only thing resembling a watchdog is agentHostTurnTracker, which derives a hang reason for telemetry and dispatches no action, so there is no path by which an abandoned turn is ever terminated.

Reproducing it

Drive a window, send a prompt that spawns a subagent, and wait. The scenario I used, with all prompts read-only:

Without changing anything, launch a subagent to inventory the top-level directories of this repository, then report what it found.

Then assert that every chat/turnStarted eventually reaches a terminal action. The run never satisfies it.

Two measurements make the diagnosis unambiguous and are worth repeating if anyone tries this:

  • check ps inside the container, to distinguish "the command is slow" from "nothing is running"
  • check whether the agent host log is still growing, rather than judging from the UI: the Stop control disappears transiently during tool execution, so the UI is not a reliable indicator of progress

Scope

Reproduced on 1.135.0 (08d4889f9ec4a1685d257b9b95de036c8e1ce1e5), dev container on Docker, agent host in the container, Claude harness, Windows client and Linux container on arm64.

I run a set of local patches against the shipped bundle, so I re-ran this against a completely stock, reverted bundle to be sure they were not the cause. It reproduces identically: the turn is still open after 10 minutes with nothing executing. As a control in the same comparison, the stock build produced 2 ENOPRO errors where the patched build produced none, which confirms the revert genuinely took effect.

What I have not established

I have not identified why the announced call is never executed. Two candidates in the existing set look most likely, and I would rather not guess between them:

  • #330899, where a client tool is admitted to execution off the stream-mapper ready rather than the runtime invocation
  • #331595, where a subagent's tool call is handled on the parent chat

Whichever it is, the missing reaper is separable and worth having on its own: a turn whose producing work is gone should not remain open forever, and today nothing can end it but the user.

Related: #332073 reports the same visible outcome from a different cause (closing the window mid-flight). The grouping is in #333174.

AI disclosure: this issue and the related investigation were written with the assistance of AI.

Public patches and patcher scripts

Public patch catalog and patcher scripts · Source patch index. The public collection includes the maintained patchers, rollback instructions, regression scripts, and historical snapshots. Build restrictions and exact installer coverage are documented there.

Activity

  1. RyanEwen commented on Sep 2, 2026

    @RyanEwen
    ContributorAuthor

    I instrumented the SDK message router to record every tool_use the host sees and every tool_result that comes back, which answers the question I left open above. The break is not the host dropping results. The results never arrive at all.

    One run, subagent spawned, nothing else touched:

    assistant uses=[toolu_01FDPu78:Agent]   parent=none        <- the spawning Task
    assistant uses=[toolu_01F2hWA5:Bash]    parent=01FDPu78
    user      results=[toolu_01F2hWA5]                          <- returned normally
    assistant uses=[toolu_01MKzyZt:Bash]    parent=01FDPu78
    user      results=[toolu_01MKzyZt]                          <- returned normally
    assistant uses=[toolu_019qg4Rx:Bash]    parent=01FDPu78     <- no result, ever
    assistant uses=[toolu_01DHweM8:Bash]    parent=01FDPu78     <- no result, ever
    

    The first two of the subagent's tool calls complete normally. The next two are announced and then the stream simply stops. The spawning Agent call never receives a result either, which is why subagent_completed never fires and the subagent turn is never closed.

    What the protocol side shows for the two stalled calls

    Both received only:

    chat/toolCallStart
    chat/toolCallReady
    

    and nothing after. Across the whole run there were zero confirmation or input-needed actions of any kind, so the user was never asked to approve anything, and there was nothing on screen to click.

    Taken with the earlier measurement that no process is executing in the container, the picture is:

    • the model announces the tool call
    • the host marks it ready
    • nothing executes it
    • no result is produced
    • no confirmation is requested
    • nothing times out

    Where that puts the defect

    The stall sits at the permission/execution boundary between the host and the SDK, not in the mapping of results. I want to be careful about the last step: I can see that no result is produced and that no confirmation is surfaced, but I cannot see from outside whether the host's canUseTool callback was invoked and never resolved, or never invoked at all. That distinction needs instrumentation inside the permission path, which I have not done.

    What is established, and reproducible:

    • results genuinely never arrive, so this is not a lost-result or mis-attribution bug
    • it happens only to a subagent's calls; the same session's earlier calls on the same subagent complete fine
    • no user-visible affordance ever appears, so there is no way for a person to unblock it
    • nothing in the product can end the resulting turn

    I have also re-confirmed on a fully stock, reverted bundle, so none of this comes from the local patches I run.

    AI disclosure: this comment and the related investigation were written with the assistance of AI.

  2. RyanEwen commented on Sep 2, 2026

    @RyanEwen
    ContributorAuthor

    I instrumented the permission callback itself, logging entry and exit separately, and that closes the diagnosis. handleCanUseTool is entered for the stalled call and never returns.

    From one run, a subagent doing ordinary read-only work:

    enter tool=Bash id=toolu_01VU8s6R
    exit  tool=Bash id=toolu_01VU8s6R behavior=allow     <- completed normally
    enter tool=Bash id=toolu_01UGw4TG
                                                         <- no exit, ever
    

    Two entries, one exit. The tool call whose permission request never returns is exactly the one left Running forever, and a third call after it never reaches canUseTool at all because the SDK is already parked behind the second.

    The chain, end to end

    1. The subagent announces a Bash tool call.
    2. The host enters handleCanUseTool for it.
    3. That call never returns. The host is parked awaiting a permission decision.
    4. No confirmation is ever surfaced. There were zero confirmation or input-needed actions in the whole run, so there is nothing on screen for a person to answer.
    5. With canUseTool unresolved the SDK never executes the tool, so no process runs and no tool_result is produced.
    6. The spawning Agent call therefore never completes, so subagent_completed never fires.
    7. completeSubagentSession is the only thing that can close a subagent turn, so the turn stays open.
    8. Nothing times out: the only watchdog reports a hang reason to telemetry and dispatches no action.

    Every step there is measured rather than inferred, except where noted below.

    Notable detail

    Not every tool call goes through this path. In the same run, two earlier Bash calls completed without entering canUseTool at all (the server tool host reported no confirmation required), and a third entered and returned allow normally. So the permission path works, and then stops working, within a single subagent.

    What is still inference

    I have not identified why the parked request is never surfaced. The obvious candidate is that the confirmation needs to be raised on the subagent's own chat channel and is not, which would match the shape of #331595, but I have not instrumented the request-surfacing path to confirm it. I would rather leave that open than guess.

    Reproduced on 1.135.0 (08d4889f9ec4a1685d257b9b95de036c8e1ce1e5), and separately on a fully stock reverted bundle, so none of this originates in the local patches I run.

    AI disclosure: this comment and the related investigation were written with the assistance of AI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions