mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-21 15:05:56 +00:00
fix(sse): keep the reasoning_content echo off DeepSeek's Claude alternate
The placeholder is an OpenAI-chat field. A DeepSeek connection on the Anthropic-compatible alternate sends Claude messages, where thinking is carried as content blocks, so skip the injection when the target format is claude.
This commit is contained in:
committed by
diegosouzapw
parent
c076efc25f
commit
b165c0fa05
@@ -1007,12 +1007,15 @@ export class DefaultExecutor extends BaseExecutor {
|
||||
|
||||
// 9router#1480: native Moonshot and DeepSeek providers 400 when a prior assistant turn lacks
|
||||
// reasoning_content (#20260). Scope to Moonshot/DeepSeek ids, or a registry entry opting in via
|
||||
// `requiresReasoningContentEcho` (e.g. `bai`'s DeepSeek resale, #13599).
|
||||
// `requiresReasoningContentEcho` (e.g. `bai`'s DeepSeek resale, #13599). The field is
|
||||
// OpenAI-chat only: a Claude alternate (DeepSeek's /anthropic endpoint) carries thinking as
|
||||
// content blocks, so the placeholder stays off that wire.
|
||||
const reasoningEcho =
|
||||
this.provider === "kimi" ||
|
||||
this.provider === "moonshot" ||
|
||||
this.provider === "deepseek" ||
|
||||
!!getRegistryEntry(this.provider)?.requiresReasoningContentEcho;
|
||||
targetFormat !== "claude" &&
|
||||
(this.provider === "kimi" ||
|
||||
this.provider === "moonshot" ||
|
||||
this.provider === "deepseek" ||
|
||||
!!getRegistryEntry(this.provider)?.requiresReasoningContentEcho);
|
||||
if (reasoningEcho) {
|
||||
const outboundModel =
|
||||
typeof (withDefaults as Record<string, unknown>)?.model === "string"
|
||||
|
||||
@@ -96,3 +96,34 @@ test("DefaultExecutor preserves existing authentic reasoning_content on deepseek
|
||||
assert.ok(assistantTurn);
|
||||
assert.equal(assistantTurn!.reasoning_content, "Authentic thinking steps here...");
|
||||
});
|
||||
|
||||
test("DefaultExecutor does not inject reasoning_content on the deepseek Claude alternate format", () => {
|
||||
// A DeepSeek connection on the Anthropic-compatible alternate sends Claude messages:
|
||||
// thinking travels as content blocks there, so the OpenAI-only field must stay off.
|
||||
const executor = new DefaultExecutor("deepseek");
|
||||
const body = {
|
||||
model: "deepseek-flash",
|
||||
max_tokens: 1024,
|
||||
stream: false,
|
||||
messages: [
|
||||
{ role: "user", content: [{ type: "text", text: "read a.txt" }] },
|
||||
{
|
||||
role: "assistant",
|
||||
content: [{ type: "tool_use", id: "toolu_1", name: "read_file", input: { path: "a.txt" } }],
|
||||
},
|
||||
{
|
||||
role: "user",
|
||||
content: [{ type: "tool_result", tool_use_id: "toolu_1", content: "hello" }],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const transformed = executor.transformRequest("deepseek-flash", body, false, {
|
||||
apiKey: "sk-deepseek-test",
|
||||
providerSpecificData: { targetFormat: "claude" },
|
||||
}) as { messages: Array<Record<string, unknown>> };
|
||||
|
||||
const assistantTurn = transformed.messages.find((m) => m.role === "assistant");
|
||||
assert.ok(assistantTurn);
|
||||
assert.equal(Object.prototype.hasOwnProperty.call(assistantTurn, "reasoning_content"), false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user