feat: add deepseek thinking mode support with reasoning_content and s…#7
feat: add deepseek thinking mode support with reasoning_content and s…#7YoungSx wants to merge 1 commit intoshantoislamdev:mainfrom
Conversation
…ignature handling - implement request conversion for thinking blocks to reasoning_content - add response conversion for reasoning_content to thinking blocks - support streaming of reasoning deltas and signatures - add automatic fallback when providers reject reasoning_content - update types for new content block types and deltas - add comprehensive test coverage for reasoning content handling
There was a problem hiding this comment.
💡 Codex Review
claude-adapter/src/converters/request.ts
Lines 271 to 274 in fffadd7
In XML tool mode, assistant history is rebuilt with only content and drops the extracted thinking data, so follow-up turns lose reasoning_content/signature replay entirely. This means the DeepSeek thinking-mode continuity fix does not apply when toolFormat is xml (the recommended mode for DeepSeek in this repo), causing the same 400 "must be passed back" class of failures on multi-turn conversations.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (merged.includes('reasoning_content') && ( | ||
| merged.includes('unknown field') || | ||
| merged.includes('invalid') || | ||
| merged.includes('not allowed') || | ||
| merged.includes('should not include') |
There was a problem hiding this comment.
Retry when providers reject reasoning_signature fields
The fallback classifier only treats errors as retryable when the message mentions reasoning_content, so requests that fail on reasoning_signature/signature (for example, unknown field reasoning_signature) will not be retried even though stripReasoningContent is designed to remove those fields. This leaves a real compatibility regression for providers that accept chat completions but reject signature fields, and the request fails instead of taking the intended one-time downgrade path.
Useful? React with 👍 / 👎.
Description
This PR fixes reasoning-content bridging for OpenAI-compatible providers (especially DeepSeek thinking/tool-call flows) with
minimal, non-breaking adapter changes.
It now preserves reasoning context bidirectionally, aligns streaming behavior with Anthropic thinking events, and adds a safe
one-time fallback when upstream providers reject reasoning fields.
Type of Change
Related Issues
Fixes #N/A
Changes Made
thinkingblocks to OpenAI-compatiblereasoning_content(andreasoning_signaturewhen available).reasoning_contentback to Anthropicthinkingblocks, including signature round-trip.reasoning_content->thinking_deltasignature_deltaonce after stripping reasoning fields.
scenarios.
Testing
Describe how you tested these changes:
Commands executed:
npm test -- reasoningContent.request.test.ts reasoningContent.response.test.ts reasoningContent.streaming.test.ts handlers.test.tsnpm run buildChecklist
Screenshots (if applicable)
N/A (backend adapter + tests only)
Additional Notes