litellm - 💡(How to fix) Fix [Bug]: LiteLlm wrapper does not surface reasoning_content from OpenAI as ReasoningMessage events when reasoning_effort is set with google adk [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#24570Fetched 2026-04-08 01:32:41
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Participants
Timeline (top)
labeled ×3

Root Cause

Root cause (suspected)

RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

Root cause (suspected)

LiteLLM populates reasoning_content on the non-streaming Message object for some providers, but for OpenAI's gpt-5.1 with reasoning_effort, the streaming Delta objects do not include a reasoning_content field — the reasoning tokens are consumed internally by OpenAI and never returned in the API response chunks. This means _extract_reasoning_value() always returns None, so no ReasoningChunk is yielded, and the ag_ui_adk EventTranslator never emits THINKING events.

Expected behavior

When reasoning_effort is set and the model performs internal reasoning, the reasoning tokens should be extracted via _extract_reasoning_value() from the LiteLLM delta (checking delta.reasoning_content), converted to Part(thought=True) parts, and emitted as THINKING events → ReasoningMessage in the AG-UI stream.

Actual behavior

No reasoning events are emitted. The _extract_reasoning_value() function in lite_llm.py calls message.get("reasoning_content") on the LiteLLM delta, but for gpt-5.1 with reasoning_effort, this field is None/absent in the streaming delta objects, even though the model does perform reasoning.

Environment

  • google-adk: 1.27.3
  • litellm: 1.82.6
  • ag-ui-adk: 0.5.1
  • model: gpt-5.1 via openai provider
  • Config: LiteLlm(model="gpt-5.1", reasoning_effort="medium")

Steps to Reproduce

Steps to reproduce

Set MODEL = LiteLlm(model="gpt-5.1", reasoning_effort="medium") Ask the agent a question that triggers reasoning + tool use Observe: no THINKING events in the AG-UI event stream The model's plan/reasoning appears as plain text content instead

Relevant log output

What part of LiteLLM is this about?

SDK (litellm Python package)

What LiteLLM version are you on ?

litellm: 1.82.6

Twitter / LinkedIn details

No response

extent analysis

Fix Plan

To fix the issue of missing reasoning events in the AG-UI stream when using the gpt-5.1 model with reasoning_effort, we need to modify the _extract_reasoning_value() function in lite_llm.py to handle the case where delta.reasoning_content is None or absent.

Here are the steps to fix the issue:

  • Modify the _extract_reasoning_value() function to check if delta.reasoning_content is None or absent, and if so, attempt to extract the reasoning tokens from the delta object using an alternative method.
  • Update the EventTranslator to emit THINKING events with the extracted reasoning tokens.

Example code:

def _extract_reasoning_value(delta):
    if delta.get("reasoning_content") is None:
        # Attempt to extract reasoning tokens from delta object
        reasoning_tokens = []
        for chunk in delta.get("chunks", []):
            if chunk.get("type") == "reasoning":
                reasoning_tokens.extend(chunk.get("tokens", []))
        return reasoning_tokens
    else:
        return delta.get("reasoning_content")

class EventTranslator:
    def __init__(self, delta):
        self.delta = delta

    def emit_thinking_events(self):
        reasoning_tokens = _extract_reasoning_value(self.delta)
        if reasoning_tokens:
            # Emit THINKING events with extracted reasoning tokens
            yield from [Part(thought=True, text=token) for token in reasoning_tokens]

Verification

To verify that the fix worked, you can test the updated code by:

  • Setting MODEL = LiteLlm(model="gpt-5.1", reasoning_effort="medium")
  • Asking the agent a question that triggers reasoning + tool use
  • Observing the AG-UI event stream for THINKING events with the extracted reasoning tokens

Extra Tips

  • Make sure to update the lite_llm.py file with the modified _extract_reasoning_value() function and EventTranslator class.
  • If you encounter any issues or errors, check the log output for any error messages or exceptions.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When reasoning_effort is set and the model performs internal reasoning, the reasoning tokens should be extracted via _extract_reasoning_value() from the LiteLLM delta (checking delta.reasoning_content), converted to Part(thought=True) parts, and emitted as THINKING events → ReasoningMessage in the AG-UI stream.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING