From 157691e16643ca6f80db356e3840ab786bee6ebd Mon Sep 17 00:00:00 2001 From: Lizandro Date: Wed, 15 Jul 2026 18:09:45 +0000 Subject: [PATCH] Fix maxOutputTokens too low for gemini-3.5-flash thinking model gemini-3.5-flash uses thinking tokens that share the same budget as output tokens. With maxOutputTokens=200 (vision) or 100 (intent), the model would exhaust the budget on thinking (~288-1043 tokens) and truncate the actual response to 8-11 tokens, producing garbage output like "040825". Fix: 2048 for vision (needs full JSON), 1024 for intent, 512 for connection test. Co-Authored-By: Claude Sonnet 4.6 --- app/Http/Livewire/Chat/ShowConfiguracionChat.php | 2 +- app/Services/GeminiIntentService.php | 2 +- app/Services/GeminiVisionService.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) mode change 100644 => 100755 app/Services/GeminiIntentService.php mode change 100644 => 100755 app/Services/GeminiVisionService.php diff --git a/app/Http/Livewire/Chat/ShowConfiguracionChat.php b/app/Http/Livewire/Chat/ShowConfiguracionChat.php index c0609dd..adf1ca2 100755 --- a/app/Http/Livewire/Chat/ShowConfiguracionChat.php +++ b/app/Http/Livewire/Chat/ShowConfiguracionChat.php @@ -110,7 +110,7 @@ class ShowConfiguracionChat extends Component $inicio = microtime(true); $body = [ 'contents' => [['parts' => [['text' => 'Responde solo "ok"']]]], - 'generationConfig' => ['maxOutputTokens' => 5, 'temperature' => 0], + 'generationConfig' => ['maxOutputTokens' => 512, 'temperature' => 0], ]; $response = Http::timeout(15) ->withHeaders(['Content-Type' => 'application/json']) diff --git a/app/Services/GeminiIntentService.php b/app/Services/GeminiIntentService.php old mode 100644 new mode 100755 index 969369b..eb250e0 --- a/app/Services/GeminiIntentService.php +++ b/app/Services/GeminiIntentService.php @@ -27,7 +27,7 @@ class GeminiIntentService { return [ 'contents' => $contents, - 'generationConfig' => array_merge(['temperature' => 0.1, 'maxOutputTokens' => 100], $genConfig), + 'generationConfig' => array_merge(['temperature' => 0.1, 'maxOutputTokens' => 1024], $genConfig), ]; } diff --git a/app/Services/GeminiVisionService.php b/app/Services/GeminiVisionService.php old mode 100644 new mode 100755 index 93fefb3..02ecf97 --- a/app/Services/GeminiVisionService.php +++ b/app/Services/GeminiVisionService.php @@ -34,7 +34,7 @@ class GeminiVisionService $body = [ 'contents' => $contents, - 'generationConfig' => ['temperature' => 0.1, 'maxOutputTokens' => 200], + 'generationConfig' => ['temperature' => 0.1, 'maxOutputTokens' => 2048], ]; $inicio = microtime(true);