fix: #2155 DeepSeek reasoning_content missing in tool call messages - #2328
Conversation
There was a problem hiding this comment.
💡 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".
5dbdcc3 to
f8c3a0f
Compare
|
@codex review again |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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
f8c3a0f to
c7fddce
Compare
|
can you fix the lint issue? |
There was a problem hiding this comment.
💡 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".
|
can you fix the mypy error? |
|
Hi Waleed, Your fix for DeepSeek's missing reasoning_content field on tool-call messages is the kind of correctness fix where confirming "the crash is gone" and confirming "tool-call behavior actually stabilized across a distribution of runs" are two different questions. The first is easy to eyeball, while the second usually is not. Since you would find out anyway if you tried it, I want to mention that when I first looked at this PR, the OpenAI Agents SDK integration for agent-eval (agent_regress) would have crashed on the very first call against any agent. It was calling a method that does not exist on the SDK's Agent class. That is fixed now. It calls the SDK's actual Runner.run() entrypoint, and I independently reproduced this end-to-end against a live openai-agents install (with 6 out of 6 integration tests passing) rather than just a unit-test mock. I am not claiming I have run agent-eval against your DeepSeek and tool-call scenario specifically, as I have not. However, the underlying idea (running an agent N times pre-fix and N times post-fix to get a Mann-Whitney p-value, Cohen's d, and bootstrap CI instead of simply eyeballing whether the 400 error is gone) is built exactly for provider-specific fixes like this one. Given you are building EMR tooling where a silent tool-call behavior shift would actually matter, I would be interested in your take on whether this is useful now that the integration itself is not broken on contact. You can find the repository here: https://github.com/RudrenduPaul/agent-eval Best, |
This PR fixes issue #2155 (400 error on tool calls due to missing
reasoning_contentin reconstructed assistant messages.)Root Cause: When DeepSeek returns a response with
reasoning_contentandtool_calls, the SDK converts it to:ResponseReasoningItem(stores reasoning insummaryfield)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_contentfield instead. It:summaryfield when processing reasoning items for DeepSeek modelspending_reasoning_contentChecks
make lintandmake format(linter shows only import resolution warnings, not code issues)Note: The fix works for both code paths:
LitellmModelwithmodel="deepseek/deepseek-reasoner"OpenAIChatCompletionsModelwithmodel="deepseek-reasoner"and DeepSeek's OpenAI-compatible endpoint