Skip to content

fix: add reasoning field fallback in ChatCompletionsTransport.parse (#1731)#1736

Open
RemyLoveLogicAI wants to merge 1 commit into
agent0ai:readyfrom
RemyLoveLogicAI:dev-workflow/1731-litellm-reasoning-fallback
Open

fix: add reasoning field fallback in ChatCompletionsTransport.parse (#1731)#1736
RemyLoveLogicAI wants to merge 1 commit into
agent0ai:readyfrom
RemyLoveLogicAI:dev-workflow/1731-litellm-reasoning-fallback

Conversation

@RemyLoveLogicAI

Copy link
Copy Markdown

Closes #1731

Summary

ChatCompletionsTransport.parse in helpers/litellm_transport.py only read reasoning from the legacy reasoning_content field. Newer vLLM / OpenAI-compatible backends (e.g. Qwen3.6 on vLLM) return reasoning under the newer reasoning field instead, causing reasoning to be silently dropped.

Fix

Added fallback checks for delta.reasoning and message.reasoning after the existing reasoning_content checks. The old field is checked first so existing providers are unaffected.

Verification

  • Non-streaming message.reasoning_content preserves reasoning (unchanged)
  • Non-streaming message.reasoning now preserves reasoning (new)
  • Streaming delta.reasoning_content preserves reasoning (unchanged)
  • Streaming delta.reasoning now preserves reasoning (new)
  • Final-answer content handling unchanged
  • Tool-call parsing unchanged
  • Existing providers returning reasoning_content see no behavior change

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

Copy link
Copy Markdown

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: a0e62acb94

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

reasoning_delta = _get_value(delta, "reasoning_content") or _get_value(
message, "reasoning_content"
) or ""
reasoning_delta = (

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Close the new reasoning_delta expression

This assignment opens a parenthesized expression but never closes it before the following return, so importing this module now fails with SyntaxError: '(' was never closed (confirmed with python -m py_compile helpers/litellm_transport.py). Because helpers/litellm_transport.py is a core transport helper, this blocks any path that imports it rather than just the new reasoning fallback.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant