feat: #2669 add opt-in reasoning content replay for chat completion models#2670
feat: #2669 add opt-in reasoning content replay for chat completion models#2670
Conversation
| # 3) response output message => assistant | ||
| elif resp_msg := cls.maybe_response_output_message(item): | ||
| flush_assistant_message() | ||
| # A reasoning item can be followed by an assistant message and then tool calls |
There was a problem hiding this comment.
This is a different bug I found during the feature addition this time.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 295691b41c
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2a143d0d7
ℹ️ 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".
This pull request adds an opt-in
should_replay_reasoning_contenthook forOpenAIChatCompletionsModelandLitellmModelto address the runtime gap discussed in #2669. The hook is evaluated in the shared Chat Completions converter with a structured context exposing{ model, base_url, reasoning }, so callers can enable provider-specific replay behavior without changing the default SDK behavior. Resolves #2669This pull request also keeps the existing one provider only default replay logic intact when no hook is provided, and fixes a converter bug where pending
reasoning_contentcould be dropped when a reasoning item was followed by an assistant output message before tool calls in the same turn. The change is covered by new regression tests for the shared converter, the direct OpenAI-compatible path, and the LiteLLM path, using generic reasoning-content model identifiers rather than provider names.