Collapses an array of tool call chunks into complete tool calls.
This function groups tool call chunks by their id and/or index, then attempts to
parse and validate the accumulated arguments for each group. Successfully parsed
tool calls are returned as valid ToolCall objects, while malformed ones are
returned as InvalidToolCall objects.
collapseToolCallChunks(chunks: ToolCallChunk<string>[]): __typeChunks are grouped using the following matching logic:
For each group, the function:
args strings from the chunksToolCall (if valid) or InvalidToolCall (if invalid)| Name | Type | Description |
|---|---|---|
chunks* | ToolCallChunk<string>[] | An array of |