@@ -6,6 +6,7 @@ import { AssistantMessageEventStream } from "../utils/event-stream.js";
66import { SYSTEM_PROMPT_CACHE_BOUNDARY } from "../utils/system-prompt-cache-boundary.js" ;
77import {
88 buildGoogleGenerateContentParams ,
9+ buildGoogleSimpleThinking ,
910 consumeGoogleGenerateContentStream ,
1011} from "./google-shared.js" ;
1112
@@ -250,3 +251,34 @@ describe("buildGoogleGenerateContentParams", () => {
250251 expect ( JSON . stringify ( params ) ) . not . toContain ( "OPENCLAW_CACHE_BOUNDARY" ) ;
251252 } ) ;
252253} ) ;
254+
255+ describe ( "buildGoogleSimpleThinking" , ( ) => {
256+ // Non-reasoning model: clampThinkingLevel clamps any non-"off" level to "off".
257+ const nonReasoningModel : Model < "google-generative-ai" > = {
258+ ...model ,
259+ id : "gemini-1.5-pro" ,
260+ name : "Gemini 1.5 Pro" ,
261+ reasoning : false ,
262+ } ;
263+
264+ it ( "disables thinking when clampThinkingLevel returns off for non-reasoning models" , ( ) => {
265+ // Before the fix, clamped "off" was mapped to "high" effort and enabled
266+ // thinking for models that cannot support it. After the fix, "off" returns
267+ // disabled thinking immediately.
268+ const result = buildGoogleSimpleThinking ( nonReasoningModel , {
269+ reasoning : "low" ,
270+ } ) ;
271+
272+ expect ( result . enabled ) . toBe ( false ) ;
273+ expect ( result . budgetTokens ) . toBeUndefined ( ) ;
274+ expect ( result . level ) . toBeUndefined ( ) ;
275+ } ) ;
276+
277+ it ( "disables thinking when reasoning is explicitly off" , ( ) => {
278+ const result = buildGoogleSimpleThinking ( model , {
279+ reasoning : "off" ,
280+ } ) ;
281+
282+ expect ( result . enabled ) . toBe ( false ) ;
283+ } ) ;
284+ } ) ;
0 commit comments