Skip to content

Commit bab9ade

Browse files
committed
test(ai): add regression coverage for clamp-to-off thinking behavior
1 parent effd885 commit bab9ade

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

packages/ai/src/providers/google-shared.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { AssistantMessageEventStream } from "../utils/event-stream.js";
66
import { SYSTEM_PROMPT_CACHE_BOUNDARY } from "../utils/system-prompt-cache-boundary.js";
77
import {
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

Comments
 (0)