From 938a0f0c9971784e810fa6465a26dd291145b6ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Mestre?= Date: Wed, 25 Feb 2026 12:58:54 -0300 Subject: [PATCH] fix: default tool call type to function for Mistral compatibility The Mistral API currently omits the `type` attribute in its tool call responses, which causes an `Undefined array key "type"` exception. This commit defaults the missing `type` to `'function'` (the standard supported type per OpenAI documentation) to prevent runtime errors and ensure broader compatibility with OpenAI-compatible APIs. Fixes #397 --- src/Responses/Chat/CreateResponseToolCall.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Responses/Chat/CreateResponseToolCall.php b/src/Responses/Chat/CreateResponseToolCall.php index b14a0776..17560b2e 100644 --- a/src/Responses/Chat/CreateResponseToolCall.php +++ b/src/Responses/Chat/CreateResponseToolCall.php @@ -13,13 +13,13 @@ private function __construct( ) {} /** - * @param array{id: string, type: string, function: array{name: string, arguments: string}} $attributes + * @param array{id: string, type?: string, function: array{name: string, arguments: string}} $attributes */ public static function from(array $attributes): self { return new self( $attributes['id'], - $attributes['type'], + $attributes['type'] ?? 'function', CreateResponseToolCallFunction::from($attributes['function']), ); }