An array of ToolCallChunk objects to collapse
An object containing:
tool_call_chunks: The original input chunkstool_calls: An array of successfully parsed and validated tool callsinvalid_tool_calls: An array of tool calls that failed parsing or validationChunks are grouped using the following matching logic:
For each group, the function:
args strings from the chunksToolCall (if valid) or InvalidToolCall (if invalid)
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
ToolCallobjects, while malformed ones are returned asInvalidToolCallobjects.