Skip to content

feat: #2669 add opt-in reasoning content replay for chat completion models#2670

Open
seratch wants to merge 4 commits intomainfrom
feat/reasoning-content-replay-opt-in
Open

feat: #2669 add opt-in reasoning content replay for chat completion models#2670
seratch wants to merge 4 commits intomainfrom
feat/reasoning-content-replay-opt-in

Conversation

@seratch
Copy link
Member

@seratch seratch commented Mar 14, 2026

This pull request adds an opt-in should_replay_reasoning_content hook for OpenAIChatCompletionsModel and LitellmModel to 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 #2669

This 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_content could 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.

# 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
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a different bug I found during the feature addition this time.

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: 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".

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: 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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

reasoning_content support for models other than DeepSeek (GLM, Kimi, etc.)

1 participant