


























@@ -5658,60 +5658,6 @@ describe("buildOpenAICompletionsParams sanitizes reasoning replay fields", () =>
56585658expect(assistant.reasoning_content).toBe("Need to answer politely.");
56595659});
566056605661-it("strips empty-string reasoning_content from OpenRouter assistant replay", () => {
5662-// DeepSeek V4 via OpenRouter injects reasoning_content: "" on tool-call
5663-// assistant messages. An empty string is technically a "string" but the
5664-// Chat Completions schema does not accept it, and OpenRouter rejects the
5665-// replayed message with HTTP 500.
5666-const params = buildOpenAICompletionsParams(
5667-openRouterModel,
5668-{
5669-systemPrompt: "system",
5670-messages: [
5671-{ role: "user", content: "read config" },
5672-{
5673-role: "assistant",
5674-provider: "openrouter",
5675-api: "openai-completions",
5676-model: "deepseek/deepseek-v4-pro",
5677-stopReason: "toolUse",
5678-timestamp: 0,
5679-content: [
5680-{
5681-type: "thinking",
5682-thinking: "",
5683-thinkingSignature: "reasoning_content",
5684-},
5685-{
5686-type: "toolCall",
5687-id: "call_1",
5688-name: "read_file",
5689-arguments: { path: "config.json" },
5690-},
5691-],
5692-},
5693-{
5694-role: "toolResult",
5695-toolCallId: "call_1",
5696-toolName: "read_file",
5697-content: [{ type: "text", text: "{ }" }],
5698-isError: false,
5699-timestamp: 1,
5700-},
5701-{ role: "user", content: "continue" },
5702-],
5703-tools: [],
5704-} as never,
5705-undefined,
5706-) as { messages: unknown };
5707-5708-const msgs = params.messages as Record<string, unknown>[];
5709-const assistantMsgs = msgs.filter((m) => m.role === "assistant");
5710-for (const msg of assistantMsgs) {
5711-expect(msg).not.toHaveProperty("reasoning_content");
5712-}
5713-});
5714-57155661it("preserves OpenRouter array reasoning_details from tool-call signatures", () => {
57165662const reasoningDetail = { type: "reasoning.encrypted", id: "rs_1", data: "ciphertext" };
57175663const params = buildOpenAICompletionsParams(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。