Skip to content

thinking: generate synthetic ID for reasoning_content without explicit ID#318933

Open
ziqiangai wants to merge 2 commits into
microsoft:mainfrom
ziqiangai:fix/deepseek-reasoning-id-312746
Open

thinking: generate synthetic ID for reasoning_content without explicit ID#318933
ziqiangai wants to merge 2 commits into
microsoft:mainfrom
ziqiangai:fix/deepseek-reasoning-id-312746

Conversation

@ziqiangai
Copy link
Copy Markdown

PR #318809 partially fixes HTTP 400 for BYOK reasoning models but misses a critical piece: getThinkingDeltaId() does not handle reasoning_content without an explicit id field.

DeepSeek/Moonshot/Minimax streaming responses include reasoning_content (text only) but do not provide cot_id, reasoning_opaque, or signature. This causes getThinkingDeltaId() to return undefined, which means extractThinkingDeltaFromChoice() returns { text } without an id.

Then in openAIEndpoint.ts, the callback guard 'if (data && data.id)' is always false, so reasoning_content is never written to the assistant message, and the second turn still fails with HTTP 400: 'The reasoning_content in the thinking mode must be passed back to the API'

Fix: Generate a synthetic monotonic ID (reasoning-1, reasoning-2, ...) when reasoning_content is present but no explicit id exists. This allows the thinking data to flow through the full pipeline and be echoed back on subsequent turns.

Fixes:

…t ID

PR microsoft#318809 partially fixes HTTP 400 for BYOK reasoning models but misses
a critical piece: getThinkingDeltaId() does not handle reasoning_content
without an explicit id field.

DeepSeek/Moonshot/Minimax streaming responses include reasoning_content
(text only) but do not provide cot_id, reasoning_opaque, or signature.
This causes getThinkingDeltaId() to return undefined, which means
extractThinkingDeltaFromChoice() returns { text } without an id.

Then in openAIEndpoint.ts, the callback guard 'if (data && data.id)'
is always false, so reasoning_content is never written to the assistant
message, and the second turn still fails with HTTP 400:
'The reasoning_content in the thinking mode must be passed back to the API'

Fix: Generate a synthetic monotonic ID (reasoning-1, reasoning-2, ...)
when reasoning_content is present but no explicit id exists. This allows
the thinking data to flow through the full pipeline and be echoed back
on subsequent turns.

Fixes microsoft#312746
Copilot AI review requested due to automatic review settings May 29, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants