From fb277672b5a68c889518bf7984ac268760bc5c60 Mon Sep 17 00:00:00 2001 From: Lukas Schaefer Date: Fri, 25 Jul 2025 13:49:18 -0400 Subject: [PATCH] Empty argument gets encoded as [] instead of {} Signed-off-by: Lukas Schaefer --- lib/Service/OpenAiAPIService.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Service/OpenAiAPIService.php b/lib/Service/OpenAiAPIService.php index 14208d9d..e124eef5 100644 --- a/lib/Service/OpenAiAPIService.php +++ b/lib/Service/OpenAiAPIService.php @@ -487,6 +487,9 @@ public function createChatCompletion( 'function' => $toolCall, ]; $formattedToolCall['function']['arguments'] = json_encode($toolCall['args']); + if ($formattedToolCall['function']['arguments'] === '[]') { + $formattedToolCall['function']['arguments'] = '{}'; + } unset($formattedToolCall['function']['id']); unset($formattedToolCall['function']['args']); unset($formattedToolCall['function']['type']);