Fix reasoning disabled by default for all providers

Previously, when reasoning was not specified, some providers like Gemini
with 'dynamic thinking' enabled by default would still use thinking.
Now explicitly sets thinkingEnabled: false (Anthropic) and
thinking: { enabled: false } (Google) when reasoning is undefined.

Closes #180
This commit is contained in:
Mario Zechner 2025-12-15 22:42:08 +01:00
parent 82dceb22e1
commit fbda78bfb3
3 changed files with 14 additions and 2 deletions

View file

@ -133,7 +133,10 @@ function mapOptionsForApi<TApi extends Api>(
switch (model.api) {
case "anthropic-messages": {
if (!options?.reasoning) return base satisfies AnthropicOptions;
// Explicitly disable thinking when reasoning is not specified
if (!options?.reasoning) {
return { ...base, thinkingEnabled: false } satisfies AnthropicOptions;
}
const anthropicBudgets = {
minimal: 1024,
@ -162,7 +165,11 @@ function mapOptionsForApi<TApi extends Api>(
} satisfies OpenAIResponsesOptions;
case "google-generative-ai": {
if (!options?.reasoning) return base as any;
// Explicitly disable thinking when reasoning is not specified
// This is needed because Gemini has "dynamic thinking" enabled by default
if (!options?.reasoning) {
return { ...base, thinking: { enabled: false } } satisfies GoogleOptions;
}
const googleModel = model as Model<"google-generative-ai">;
const effort = clampReasoning(options.reasoning)!;