From fbda78bfb3dad67886b13846f3f44b4fed9e4d28 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 15 Dec 2025 22:42:08 +0100 Subject: [PATCH] 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 --- packages/ai/CHANGELOG.md | 4 ++++ packages/ai/src/stream.ts | 11 +++++++++-- packages/coding-agent/CHANGELOG.md | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 43e2832c..b18daec7 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- **Reasoning disabled by default**: When `reasoning` option is not specified, thinking is now explicitly disabled for all providers. Previously, some providers like Gemini with "dynamic thinking" would use their default (thinking ON), causing unexpected token usage. This was the original intended behavior. ([#180](https://github.com/badlogic/pi-mono/pull/180) by [@markusylisiurunen](https://github.com/markusylisiurunen)) + ## [0.22.2] - 2025-12-15 ### Added diff --git a/packages/ai/src/stream.ts b/packages/ai/src/stream.ts index adf37357..382abd14 100644 --- a/packages/ai/src/stream.ts +++ b/packages/ai/src/stream.ts @@ -133,7 +133,10 @@ function mapOptionsForApi( 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( } 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)!; diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 0057dbb8..4ea1d1b4 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -5,6 +5,7 @@ ### Fixed - Improved RGB to 256-color mapping for terminals without truecolor support. Now correctly uses grayscale ramp for neutral colors and preserves semantic tints (green for success, red for error, blue for pending) instead of mapping everything to wrong cube colors. +- `/think off` now actually disables thinking for all providers. Previously, providers like Gemini with "dynamic thinking" enabled by default would still use thinking even when turned off. ([#180](https://github.com/badlogic/pi-mono/pull/180) by [@markusylisiurunen](https://github.com/markusylisiurunen)) ## [0.22.2] - 2025-12-15