Skip to content

Conversation

@wahmd
Copy link
Contributor

@wahmd wahmd commented Jan 18, 2026

This PR fixes issue #2155 (400 error on tool calls due to missing reasoning_content in reconstructed assistant messages.)

Root Cause: When DeepSeek returns a response with reasoning_content and tool_calls, the SDK converts it to:

  • A ResponseReasoningItem (stores reasoning in summary field)
  • A ResponseFunctionToolCall (stores tool call)

On the next API call, Converter.items_to_messages() reconstructs the assistant message with tool calls, but was only handling reasoning content for Anthropic/Claude models (via thinking blocks), not DeepSeek.

Solution: The fix follows the same pattern as Anthropic's thinking blocks but uses DeepSeek's reasoning_content field instead. It:

  1. Extracts reasoning text from the summary field when processing reasoning items for DeepSeek models
  2. Stores it temporarily in pending_reasoning_content
  3. Adds it to the assistant message when tool calls are processed

Checks

  • I've added new tests
  • I've run make lint and make format (linter shows only import resolution warnings, not code issues)
  • I've made sure tests pass

Note: The fix works for both code paths:

  • LiteLLM path: When using LitellmModel with model="deepseek/deepseek-reasoner"
  • OpenAI ChatCompletions path: When using OpenAIChatCompletionsModel with model="deepseek-reasoner" and DeepSeek's OpenAI-compatible endpoint

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5dbdcc302a

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@seratch
Copy link
Member

seratch commented Jan 18, 2026

@codex review again

@seratch seratch marked this pull request as draft January 18, 2026 23:03
@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ 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".

- Add pending_reasoning_content tracking for DeepSeek models
- Extract reasoning content from summary field in reasoning items
- Apply reasoning_content to assistant messages with tool_calls
- Works for both LiteLLM and OpenAI ChatCompletions paths

Fixes openai#2155
@wahmd wahmd force-pushed the fix/deepseek-reasoning-content branch from f8c3a0f to c7fddce Compare January 19, 2026 00:08
@seratch
Copy link
Member

seratch commented Jan 19, 2026

can you fix the lint issue?

@wahmd wahmd marked this pull request as ready for review January 19, 2026 00:34
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: df5e138c48

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@seratch
Copy link
Member

seratch commented Jan 19, 2026

can you fix the mypy error?

@seratch seratch added this to the 0.6.x milestone Jan 19, 2026
@seratch seratch merged commit 8455af0 into openai:main Jan 19, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants