@@ -369,18 +369,20 @@ def _build_generation_params(
369369
370370 def _maybe_unset_thinking_budget (self , generation_params : Dict [str , Any ]):
371371 try :
372- # There's no way to introspect on model capabilities, so
373- # to check for models that we know default to thinkin on
374- # and can be configured to turn it off.
375- if not self ._settings .model .startswith ("gemini-2.5-flash" ):
376- return
377- # If we have an image model, we don't use a budget either.
372+ # If we have an image model, we don't apply a thinking default.
378373 if "image" in self ._settings .model :
379374 return
380375 # If thinking_config is already set, don't override it.
381376 if "thinking_config" in generation_params :
382377 return
383- generation_params .setdefault ("thinking_config" , {})["thinking_budget" ] = 0
378+ # Apply model-aware low-latency thinking defaults.
379+ # Gemini 2.5 Flash: disable thinking via thinking_budget.
380+ # Gemini 3+ Flash: use minimal thinking via thinking_level.
381+ model = self ._settings .model
382+ if model .startswith ("gemini-2.5-flash" ):
383+ generation_params ["thinking_config" ] = {"thinking_budget" : 0 }
384+ elif model .startswith ("gemini-3" ) and "flash" in model :
385+ generation_params ["thinking_config" ] = {"thinking_level" : "minimal" }
384386 except Exception as e :
385387 logger .error (f"Failed to unset thinking budget: { e } " )
386388
0 commit comments