fix(gemini-cli): raise output floor for thinking and add validated toolConfig (#2486)

Gemini CLI requests with small max_tokens spend the whole output budget on
thoughts after reasoning_effort maps to thinkingConfig, returning blank
content or finish=length. Raise maxOutputTokens floors per thinking level/
budget (clamped to caps.maxOutput). Also emit toolConfig
functionCallingConfig.mode=VALIDATED for Gemini CLI tool requests to avoid
MALFORMED_FUNCTION_CALL.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
DOMANHDUC
2026-07-10 11:32:11 +07:00
committed by decolua
co-authored by Cursor
parent 0d4d4bc261
commit 7610f28f42
4 changed files with 107 additions and 12 deletions
+39
View File
@@ -54,6 +54,45 @@ describe("GOLDEN request: OpenAI → Gemini", () => {
const out = translateRequest(FORMATS.OPENAI, FORMATS.GEMINI, "gemini-3-pro", baseBody(), true, { apiKey: "k" }, "gemini");
expect(clean(out)).toMatchSnapshot();
});
it("Gemini CLI tool requests include validated toolConfig and enough output for high thinking", () => {
const body = {
messages: [{ role: "user", content: "Call add with 7 and 35." }],
tools: [
{
type: "function",
function: {
name: "add",
description: "Add two numbers",
parameters: {
type: "object",
properties: {
a: { type: "number" },
b: { type: "number" },
},
required: ["a", "b"],
},
},
},
],
reasoning_effort: "high",
max_tokens: 128,
};
const out = translateRequest(
FORMATS.OPENAI,
FORMATS.GEMINI_CLI,
"gemini-3.1-pro-preview",
body,
true,
{ accessToken: "t", projectId: "p" },
"gemini-cli"
);
expect(out.request.toolConfig).toEqual({ functionCallingConfig: { mode: "VALIDATED" } });
expect(out.request.safetySettings).toBeDefined();
expect(out.request.generationConfig.thinkingConfig).toEqual({ thinkingLevel: "high", includeThoughts: true });
expect(out.request.generationConfig.maxOutputTokens).toBe(65535);
});
});
describe("GOLDEN request: OpenAI → Kiro", () => {