mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
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:
committed by
decolua
co-authored by
Cursor
parent
0d4d4bc261
commit
7610f28f42
@@ -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", () => {
|
||||
|
||||
@@ -78,11 +78,27 @@ describe("applyThinking per provider format", () => {
|
||||
const out = apply("gemini", "gemini-3-pro", { reasoning_effort: "auto" }, "gemini");
|
||||
expect(out.generationConfig.thinkingConfig.thinkingLevel).toBe("high");
|
||||
});
|
||||
it("gemini-3 high thinking raises too-small maxOutputTokens", () => {
|
||||
const out = apply("gemini-cli", "gemini-3.1-pro-preview", {
|
||||
request: { generationConfig: { maxOutputTokens: 128 } },
|
||||
reasoning_effort: "high",
|
||||
}, "gemini-cli");
|
||||
expect(out.request.generationConfig.thinkingConfig).toEqual({ thinkingLevel: "high", includeThoughts: true });
|
||||
expect(out.request.generationConfig.maxOutputTokens).toBe(65535);
|
||||
});
|
||||
it("gemini-2.5 → thinkingBudget", () => {
|
||||
const out = apply("gemini", "gemini-2.5-flash", { reasoning_effort: "high" }, "gemini");
|
||||
expect(out.generationConfig.thinkingConfig.thinkingBudget).toBe(24576);
|
||||
expect(out.generationConfig.thinkingConfig.thinkingLevel).toBeUndefined();
|
||||
});
|
||||
it("gemini-2.5 budget thinking keeps enough room for answer tokens", () => {
|
||||
const out = apply("gemini-cli", "gemini-2.5-pro", {
|
||||
request: { generationConfig: { maxOutputTokens: 1024 } },
|
||||
reasoning_effort: "high",
|
||||
}, "gemini-cli");
|
||||
expect(out.request.generationConfig.thinkingConfig).toEqual({ thinkingBudget: 24576, includeThoughts: true });
|
||||
expect(out.request.generationConfig.maxOutputTokens).toBe(32768);
|
||||
});
|
||||
it("GLM off → enable_thinking:false (not thinking.disabled)", () => {
|
||||
const out = apply("openai", "glm-4.6", { reasoning_effort: "none" }, "glm");
|
||||
expect(out.enable_thinking).toBe(false);
|
||||
|
||||
Reference in New Issue
Block a user