thinking: generate synthetic ID for reasoning_content without explicit ID#318933
Open
ziqiangai wants to merge 2 commits into
Open
thinking: generate synthetic ID for reasoning_content without explicit ID#318933ziqiangai wants to merge 2 commits into
ziqiangai wants to merge 2 commits into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
reasoning_contentnot echoed back) #318920