Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
/**
* #6813 (defect 1) — the openai->gemini transform forwards the Claude-style
* `thinking.budget_tokens` into `generationConfig.thinkingConfig.thinkingBudget`, but the
* presence check was truthy (`&& thinking.budget_tokens`). An explicit `budget_tokens: 0`
* (the natural "disable thinking" request) is falsy, so it was dropped and the request fell
* through to the default thinkingConfig injection — the model thought despite an explicit
* request for zero. A `budget_tokens: 0` must be honored as thinkingBudget: 0.
*/
import test from "node:test";
import assert from "node:assert/strict";
const { openaiToGeminiRequest } = await import(
"../../open-sse/translator/request/openai-to-gemini.ts"
);
test("thinking.budget_tokens: 0 is honored as thinkingBudget 0 (not dropped) (#6813)", () => {
const result = openaiToGeminiRequest(
"gemini-2.5-flash",
{
messages: [{ role: "user", content: "hi" }],
thinking: { type: "enabled", budget_tokens: 0 },
},
false
) as { generationConfig: { thinkingConfig?: { thinkingBudget: number; includeThoughts: boolean } } };
assert.equal(
result.generationConfig.thinkingConfig?.thinkingBudget,
0,
"explicit budget_tokens: 0 must map to thinkingBudget: 0"
);
assert.equal(
result.generationConfig.thinkingConfig?.includeThoughts,
false,
"with a zero budget there are no thoughts to include"
);
});
test("thinking.budget_tokens: positive value still maps through with includeThoughts true (#6813 no-regression)", () => {
const result = openaiToGeminiRequest(
"gemini-2.5-flash",
{
messages: [{ role: "user", content: "hi" }],
thinking: { type: "enabled", budget_tokens: 2048 },
},
false
) as { generationConfig: { thinkingConfig?: { thinkingBudget: number; includeThoughts: boolean } } };
assert.equal(result.generationConfig.thinkingConfig?.thinkingBudget, 2048);
assert.equal(result.generationConfig.thinkingConfig?.includeThoughts, true);
});