mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
fix provider thinking compatibility
- claude: handle DeepSeek thinking blocks defensively, unsigned placeholder; fix kept-vs-seen thinking detection - gemini: clamp unsupported max/xhigh thinking levels to high - testUtils: probe Cloud Code Assist for gemini-cli/antigravity with 401 refresh retry - tests: add translator regression coverage Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
decolua
co-authored by
Cursor
parent
cb65a45e1f
commit
c4f80d30d8
@@ -3,6 +3,7 @@ import { describe, it, expect } from "vitest";
|
||||
import "./registerAll.js";
|
||||
import { translateRequest } from "../../open-sse/translator/index.js";
|
||||
import { FORMATS } from "../../open-sse/translator/formats.js";
|
||||
import { prepareClaudeRequest } from "../../open-sse/translator/formats/claude.js";
|
||||
|
||||
// anthropic-compatible provider so prepareClaudeRequest runs the openai→claude path
|
||||
const T = (body) =>
|
||||
@@ -16,9 +17,7 @@ describe("OpenAI → Claude context mapping", () => {
|
||||
expect(JSON.stringify(out.system), "Claude Code prompt injected").not.toContain("Claude Code");
|
||||
});
|
||||
|
||||
// openai-to-claude.js:268-273 — assistant.reasoning_content not mapped to a thinking block
|
||||
// KNOWN BUG
|
||||
it.fails("assistant reasoning_content becomes a thinking block", () => {
|
||||
it("assistant reasoning_content becomes a thinking block", () => {
|
||||
const out = T({
|
||||
messages: [
|
||||
{ role: "user", content: "q" },
|
||||
@@ -27,6 +26,11 @@ describe("OpenAI → Claude context mapping", () => {
|
||||
],
|
||||
});
|
||||
expect(JSON.stringify(out), "reasoning_content lost").toContain("my hidden reasoning");
|
||||
const assistant = out.messages.find((m) => m.role === "assistant");
|
||||
expect(assistant.content[0]).toEqual(expect.objectContaining({
|
||||
type: "thinking",
|
||||
thinking: "my hidden reasoning",
|
||||
}));
|
||||
});
|
||||
|
||||
// openai-to-claude.js:298 — tool_choice "none" mapped to {type:"auto"} (loses "do not call" intent)
|
||||
@@ -62,4 +66,22 @@ describe("OpenAI → Claude context mapping", () => {
|
||||
});
|
||||
expect(JSON.stringify(out), "remote image dropped").toContain("pic.png");
|
||||
});
|
||||
|
||||
it("DeepSeek Claude transport adds a thinking placeholder before tool_use in thinking mode", () => {
|
||||
const out = prepareClaudeRequest({
|
||||
model: "deepseek-v4-pro",
|
||||
thinking: { type: "enabled" },
|
||||
messages: [
|
||||
{ role: "user", content: [{ type: "text", text: "q" }] },
|
||||
{ role: "assistant", content: [{ type: "tool_use", id: "toolu_1", name: "Read", input: { file_path: "x" } }] },
|
||||
{ role: "user", content: [{ type: "tool_result", tool_use_id: "toolu_1", content: "ok" }] },
|
||||
{ role: "user", content: [{ type: "text", text: "continue" }] },
|
||||
],
|
||||
}, "deepseek");
|
||||
|
||||
const assistant = out.messages.find((m) => m.role === "assistant");
|
||||
expect(assistant.content[0]).toEqual({ type: "thinking", thinking: "." });
|
||||
expect(assistant.content[1]).toEqual(expect.objectContaining({ type: "tool_use", id: "toolu_1" }));
|
||||
expect(assistant.content[0].signature).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -68,6 +68,16 @@ describe("applyThinking per provider format", () => {
|
||||
const out = apply("gemini", "gemini-3-pro", { reasoning_effort: "medium" }, "gemini");
|
||||
expect(out.generationConfig.thinkingConfig.thinkingLevel).toBe("medium");
|
||||
});
|
||||
it("gemini-3 clamps unsupported max/xhigh thinking levels to high", () => {
|
||||
const outMax = apply("gemini", "gemini-3-pro", { reasoning_effort: "max" }, "gemini");
|
||||
const outXhigh = apply("gemini", "gemini-3-pro", { reasoning_effort: "xhigh" }, "gemini");
|
||||
expect(outMax.generationConfig.thinkingConfig.thinkingLevel).toBe("high");
|
||||
expect(outXhigh.generationConfig.thinkingConfig.thinkingLevel).toBe("high");
|
||||
});
|
||||
it("gemini-3 maps auto thinking level to high instead of sending unsupported auto", () => {
|
||||
const out = apply("gemini", "gemini-3-pro", { reasoning_effort: "auto" }, "gemini");
|
||||
expect(out.generationConfig.thinkingConfig.thinkingLevel).toBe("high");
|
||||
});
|
||||
it("gemini-2.5 → thinkingBudget", () => {
|
||||
const out = apply("gemini", "gemini-2.5-flash", { reasoning_effort: "high" }, "gemini");
|
||||
expect(out.generationConfig.thinkingConfig.thinkingBudget).toBe(24576);
|
||||
|
||||
Reference in New Issue
Block a user