Description
When using the Groq provider with streaming enabled and tool calling, mapToolCalls() in Stream.php can crash with:
ToolCall::__construct(): Argument #1 ($id) must be of type string, null given
This happens because Groq's streaming API sometimes sends tool call deltas where the id field is null. The ID arrives in an earlier chunk and is not repeated in subsequent argument chunks.
Current behaviour
return new ToolCall(
data_get($toolCall, 'id'), // can be null for streaming deltas
data_get($toolCall, 'name'),
$arguments,
);
ToolCall::__construct() requires $id to be a non-null string, so this throws a TypeError and the entire streaming response fails.
Expected behaviour
The handler should either accumulate streaming deltas before constructing ToolCall objects, or use a stable fallback ID when the delta does not include one.
Steps to reproduce
- Configure Groq as your provider.
- Define one or more tools on your agent.
- Send a message that triggers tool use.
- Observe the
TypeError in the streaming response.
Environment
prism-php/prism v0.99.22
- Provider: Groq (streaming)
- PHP 8.4
Description
When using the Groq provider with streaming enabled and tool calling,
mapToolCalls()inStream.phpcan crash with:This happens because Groq's streaming API sometimes sends tool call deltas where the
idfield isnull. The ID arrives in an earlier chunk and is not repeated in subsequent argument chunks.Current behaviour
ToolCall::__construct()requires$idto be a non-nullstring, so this throws aTypeErrorand the entire streaming response fails.Expected behaviour
The handler should either accumulate streaming deltas before constructing
ToolCallobjects, or use a stable fallback ID when the delta does not include one.Steps to reproduce
TypeErrorin the streaming response.Environment
prism-php/prismv0.99.22