Skip to content

GEMINI: Prism\Prism\ValueObjects\ToolCall::__construct(): Argument #1 ($id) must be of type string, null given #811

@vpuentem

Description

@vpuentem

When using Prism with Gemini provider (gemini-2.5-flash) with withMessages(), withTools(), and withMaxSteps(), the request fails with a 500 Internal Server Error.

"Prism\Prism\ValueObjects\ToolCall::__construct(): Argument #1 ($id) must be of type string, null given, called in ...\vendor\prism-php\prism\src\Providers\Gemini\Maps\ToolCallMap.php on line 21"

Code Example

$tools=[
     Tool::as('tool_name')
           ->for('Tool definition.')
           ->withBooleanParameter('parameter', 'Parameter definition')
           ->using(fn () => ''),

$messages = [
    new UserMessage('Previous user message'),
    new AssistantMessage('Previous assistant response'),
    new UserMessage('Current user message'),
];

$response = Prism::text()
    ->using(Provider::Gemini, 'gemini-2.5-flash')
    ->withSystemPrompt('System prompt here')
    ->withMessages($messages)
    ->withTools($tools) // Array of Tool objects
    ->withMaxSteps(2)
    ->asText();

It doesn't happens all the time, only between requests that require tool usage. Not sure if its a gemini issue because i'm using '' as tool execution code, this is because i'm executing some tools in the frontend, so i pass the tool usage as a response.

This also happened with other gemini versions

Any help would be appreciated, i can also create a PR if its a provider definition issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions