Skip to content

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

Merge branch release/v3.8.6 into fix/interleaved-reasoning-replay-gating (resolve conflict)

diegosouzapwdd5098bf6753
diff --cc tests/unit/translator-helper-branches.test.ts
index 3ef8d03a7e,7266db3df5..9d14c83137
--- a/tests/unit/translator-helper-branches.test.ts
+++ b/tests/unit/translator-helper-branches.test.ts
@@@ -514,18 -527,55 +552,65 @@@ test("toolCallHelper normalizes ids, li
assert.deepEqual(toolCallHelper.fixMissingToolResponses({ messages: null }), { messages: null });
});
+ test("fixMissingToolResponses inserts Claude tool_result block when assistant uses Claude shape", () => {
+ const fixed = toolCallHelper.fixMissingToolResponses({
+ messages: [
+ { role: "user", content: [{ type: "text", text: "do it" }] },
+ {
+ role: "assistant",
+ content: [
+ { type: "tool_use", id: "tool_a", name: "bash", input: { cmd: "ls" } },
+ { type: "tool_use", id: "tool_b", name: "bash", input: { cmd: "pwd" } },
+ ],
+ },
+ { role: "user", content: [{ type: "text", text: "continue" }] },
+ ],
+ });
+
+ assert.equal(fixed.messages.length, 4);
+ const inserted = fixed.messages[2];
+ assert.equal(inserted.role, "user");
+ assert.ok(Array.isArray(inserted.content));
+ assert.equal(inserted.content.length, 2);
+ assert.equal(inserted.content[0].type, "tool_result");
+ assert.equal(inserted.content[0].tool_use_id, "tool_a");
+ assert.equal(inserted.content[0].content, "");
+ assert.equal(inserted.content[1].tool_use_id, "tool_b");
+ });
+
+ test("fixMissingToolResponses keeps OpenAI role:tool when assistant uses OpenAI tool_calls", () => {
+ const fixed = toolCallHelper.fixMissingToolResponses({
+ messages: [
+ {
+ role: "assistant",
+ tool_calls: [
+ { id: "call_a", type: "function", function: { name: "lookup", arguments: "{}" } },
+ { id: "call_b", type: "function", function: { name: "search", arguments: "{}" } },
+ ],
+ },
+ { role: "user", content: "no tool result here" },
+ ],
+ });
+
+ assert.equal(fixed.messages.length, 4);
+ assert.equal(fixed.messages[1].role, "tool");
+ assert.equal(fixed.messages[1].tool_call_id, "call_a");
+ assert.equal(fixed.messages[2].role, "tool");
+ assert.equal(fixed.messages[2].tool_call_id, "call_b");
+ });
+
-test("translateRequest replays cached DeepSeek reasoning messages without tool calls", () => {
+test("translateRequest replays cached reasoning-only messages when interleaved field is reasoning_content", () => {
clearReasoningCacheAll();
+ clearModelsDevCapabilities();
+ saveModelsDevCapabilities({
+ deepseek: {
+ "deepseek-v4-flash": buildCapability({
+ interleaved_field: "reasoning_content",
+ reasoning: true,
+ tool_call: true,
+ }),
+ },
+ });
cacheReasoningByKey(
"request:req_reasoning_only:message:0",
"deepseek",
@@@ -580,9 -629,10 +665,10 @@@ test("translateRequest does not replay
"kimi"
);
- assert.equal(result.messages[1].reasoning_content, "");
+ assert.equal(result.messages[1].reasoning_content, undefined);
assert.equal(getReasoningCacheServiceStats().replays, 0);
clearReasoningCacheAll();
+ });
test("translateRequest injects thinking block into Claude-format messages for Kimi K2 reasoning models", () => {
clearReasoningCacheAll();