






















@@ -5609,6 +5609,60 @@ describe("buildOpenAICompletionsParams sanitizes reasoning replay fields", () =>
56095609expect(assistant.reasoning_content).toBe("Need to answer politely.");
56105610});
561156115612+it("strips empty-string reasoning_content from OpenRouter assistant replay", () => {
5613+// DeepSeek V4 via OpenRouter injects reasoning_content: "" on tool-call
5614+// assistant messages. An empty string is technically a "string" but the
5615+// Chat Completions schema does not accept it, and OpenRouter rejects the
5616+// replayed message with HTTP 500.
5617+const params = buildOpenAICompletionsParams(
5618+openRouterModel,
5619+{
5620+systemPrompt: "system",
5621+messages: [
5622+{ role: "user", content: "read config" },
5623+{
5624+role: "assistant",
5625+provider: "openrouter",
5626+api: "openai-completions",
5627+model: "deepseek/deepseek-v4-pro",
5628+stopReason: "toolUse",
5629+timestamp: 0,
5630+content: [
5631+{
5632+type: "thinking",
5633+thinking: "",
5634+thinkingSignature: "reasoning_content",
5635+},
5636+{
5637+type: "toolCall",
5638+id: "call_1",
5639+name: "read_file",
5640+arguments: { path: "config.json" },
5641+},
5642+],
5643+},
5644+{
5645+role: "toolResult",
5646+toolCallId: "call_1",
5647+toolName: "read_file",
5648+content: [{ type: "text", text: "{ }" }],
5649+isError: false,
5650+timestamp: 1,
5651+},
5652+{ role: "user", content: "continue" },
5653+],
5654+tools: [],
5655+} as never,
5656+undefined,
5657+) as { messages: unknown };
5658+5659+const msgs = params.messages as Record<string, unknown>[];
5660+const assistantMsgs = msgs.filter((m) => m.role === "assistant");
5661+for (const msg of assistantMsgs) {
5662+expect(msg).not.toHaveProperty("reasoning_content");
5663+}
5664+});
5665+56125666it("preserves OpenRouter array reasoning_details from tool-call signatures", () => {
56135667const reasoningDetail = { type: "reasoning.encrypted", id: "rs_1", data: "ciphertext" };
56145668const params = buildOpenAICompletionsParams(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。