Problem
The Chunk union's tool-call variant currently carries only toolName and input:
{
type: "tool-call";
toolName: string;
input: Record<string, unknown>;
}
There is no toolCallId (or equivalent identifier) that links a tool invocation to its result, and tool_result is not a first-class event — it arrives as { type: "unknown"; event: "tool_result"; data: unknown }.
This causes two concrete issues:
1. Parallel tool calls produce incorrect result matching
Claude Code (and other agents built on the Anthropic SDK) routinely execute multiple tool calls in a single turn. Because there is no identifier tying a result back to its originating call, consumers are forced to use a fragile heuristic — typically "assign the result to the first tool call that has no result yet." When two or more calls are in flight simultaneously, results can be attributed to the wrong call.
2. Tool results cannot be given a structured type
Without a discriminant linking a result to a known tool name, the result payload cannot be narrowed to the tool-specific output schema (e.g. FileReadOutput, BashOutput). Consumers must treat every result as unknown or string, losing the type safety that the Anthropic Agent SDK otherwise provides.
Proposed changes
a. Add toolCallId to the tool-call chunk
{
type: "tool-call";
toolCallId: string; // new
toolName: string;
input: Record<string, unknown>;
}
b. Add a first-class tool-result chunk
{
type: "tool-result";
toolCallId: string;
output: unknown; // or a structured union
}
This removes the need for consumers to intercept type: "unknown" events and parse tool_result manually.
Context
@upstash/box version: 0.1.31
- The Anthropic Agent SDK's own streaming format already includes a
tool_use_id that uniquely identifies each tool invocation. Surfacing this through the Box SDK would bring parity with the upstream protocol.
Problem
The
Chunkunion'stool-callvariant currently carries onlytoolNameandinput:There is no
toolCallId(or equivalent identifier) that links a tool invocation to its result, andtool_resultis not a first-class event — it arrives as{ type: "unknown"; event: "tool_result"; data: unknown }.This causes two concrete issues:
1. Parallel tool calls produce incorrect result matching
Claude Code (and other agents built on the Anthropic SDK) routinely execute multiple tool calls in a single turn. Because there is no identifier tying a result back to its originating call, consumers are forced to use a fragile heuristic — typically "assign the result to the first tool call that has no result yet." When two or more calls are in flight simultaneously, results can be attributed to the wrong call.
2. Tool results cannot be given a structured type
Without a discriminant linking a result to a known tool name, the result payload cannot be narrowed to the tool-specific output schema (e.g.
FileReadOutput,BashOutput). Consumers must treat every result asunknownorstring, losing the type safety that the Anthropic Agent SDK otherwise provides.Proposed changes
a. Add
toolCallIdto thetool-callchunkb. Add a first-class
tool-resultchunkThis removes the need for consumers to intercept
type: "unknown"events and parsetool_resultmanually.Context
@upstash/boxversion: 0.1.31tool_use_idthat uniquely identifies each tool invocation. Surfacing this through the Box SDK would bring parity with the upstream protocol.