-
Notifications
You must be signed in to change notification settings - Fork 943
Description
** 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
- Create a session with the SDK that has access to the task agent type
- Send a prompt that triggers a task() tool call (subagent delegation)
- Observe assistant.message_delta events — parentToolCallId is undefined
- Observe the final assistant.message — parentToolCallId is correctly set
SDK: 0.1.32
CLI: 1.0.2