Skip to content

BUG: Subagent assistant message deltas don't include parentToolCallId #739

@knifeyspoony

Description

@knifeyspoony

** Summary**

When a subagent is spawned via the task() tool, streaming assistant.message_delta events do not include parentToolCallId. Only the final assistant.message event carries it. This makes it impossible for SDK consumers to attribute streaming deltas to the correct subagent in real time.

Expected behavior

assistant.message_delta events emitted during a subagent turn should include parentToolCallId (the tool call ID of the task() invocation that spawned the subagent), matching the behavior of the final assistant.message event.

Actual behavior

The single emit site for assistant.message_delta only passes { messageId, deltaContent }:

// index.js (bundled CLI) — only emit site for assistant.message_delta
this.session.emitEphemeral("assistant.message_delta", {
messageId: this.currentMessageId,
deltaContent: n
});

Meanwhile, the final message correctly includes it:

this.emit("assistant.message", {
parentToolCallId: Q,
messageId: mi(),
content: ...
});

The session event schema already defines parentToolCallId as optional on assistant.message_delta:

// generated/session-events.ts
type: "assistant.message_delta",
data: {
messageId: string;
deltaContent: string;
parentToolCallId?: string; // ← defined but never populated
}

Reproduction

  1. Create a session with the SDK that has access to the task agent type
  2. Send a prompt that triggers a task() tool call (subagent delegation)
  3. Observe assistant.message_delta events — parentToolCallId is undefined
  4. Observe the final assistant.message — parentToolCallId is correctly set

SDK: 0.1.32
CLI: 1.0.2

Metadata

Metadata

Assignees

No one assigned

    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