From 784ee9a4da861abc33956903e736f2fbbee8391f Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Fri, 24 Apr 2026 05:09:16 -0700 Subject: [PATCH] AIX: DeepSeek V4: wires and parser NS --- .../server/dispatch/chatGenerate/parsers/openai.parser.ts | 4 ++++ .../aix/server/dispatch/wiretypes/openai.wiretypes.ts | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/modules/aix/server/dispatch/chatGenerate/parsers/openai.parser.ts b/src/modules/aix/server/dispatch/chatGenerate/parsers/openai.parser.ts index 519e76014..e0d5e4c1d 100644 --- a/src/modules/aix/server/dispatch/chatGenerate/parsers/openai.parser.ts +++ b/src/modules/aix/server/dispatch/chatGenerate/parsers/openai.parser.ts @@ -494,6 +494,10 @@ export function createOpenAIChatCompletionsParserNS(): ChatGenerateParseFunction } else if (message.content !== undefined && message.content !== null) throw new Error(`unexpected message content type: ${typeof message.content}`); + // [DeepSeek, 2026-04-24] Non-streaming reasoning_content -> 'ma' reasoning part (mirror of streaming path above) + if (typeof message.reasoning_content === 'string' && message.reasoning_content) + pt.appendReasoningText(message.reasoning_content); + // [OpenRouter, 2025-01-20] Handle structured reasoning_details if (Array.isArray(message.reasoning_details)) { for (const reasoningDetail of message.reasoning_details) { diff --git a/src/modules/aix/server/dispatch/wiretypes/openai.wiretypes.ts b/src/modules/aix/server/dispatch/wiretypes/openai.wiretypes.ts index c83267e91..4097d24bf 100644 --- a/src/modules/aix/server/dispatch/wiretypes/openai.wiretypes.ts +++ b/src/modules/aix/server/dispatch/wiretypes/openai.wiretypes.ts @@ -189,6 +189,13 @@ export namespace OpenAIWire_Messages { /** [OpenRouter, 2025-01-20] Reasoning traces with multiple blocks (summary, text, encrypted). */ reasoning_details: z.array(OpenAIWire_ContentParts.OpenRouter_ReasoningDetail_schema).optional(), + /** + * [DeepSeek, 2026-04-24] Chain-of-thought reasoning text. + * - Response: emitted by V4 thinking-by-default; parsed into a 'ma' reasoning part. + * - (this) Request: MUST be echoed back on assistant turns that carry tool_calls (otherwise HTTP 400: "The reasoning_content in the thinking mode must be passed back to the API."). + */ + reasoning_content: z.string().nullable().optional(), + // function_call: // ignored, as it's deprecated // name: _optionalParticipantName, // omitted by choice: generally unsupported });