adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

LiteLlm wrapper does not surface reasoning_content from OpenAI model as ReasoningMessage events when reasoning_effort is set

Open deepakbatham572 opened this issue 8 months ago • 5 comments

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")

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.

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.

Steps to reproduce

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

deepakbatham572 avatar Mar 24 '26 17:03 deepakbatham572

This issue has been automatically marked as stale because it has not had recent activity for 7 days after a maintainer requested clarification. It will be closed if no further activity occurs within 7 days.

adk-bot avatar May 02 '26 06:05 adk-bot

/adk-issue-analyze

surajksharma07 avatar Jun 05 '26 07:06 surajksharma07

Hi @deepakbatham572 , thanks for bringing up this issue. I believe your suspected root cause is right, that OpenAI does not return raw reasoning tokens.

In OpenAI's docs, it's mentioned that raw reasoning tokens are not exposed by the model, but you have the option to view a reasoning summary. I believe that with the summary disabled, OpenAI might not return a model response with reasoning content, which leads to liteLLM and ADK being unable to surface it.

Under the liteLLM docs, there's more information about how to set up reasoning summaries. The main points are:

  • In order to access reasoning summaries, your OpenAI organization or account needs to have verification status
  • For reasoning outputs, it's recommended to route completion requests to OpenAI's Responses API. This can be done by using a openai/responses/ prefix. For example, use openai/responses/gpt-5.1 rather than gpt-5.1.
  • To get reasoning summaries, you can pass in reasoning_effort as dictionary with a summary parameter. For example reasoning_effort={"effort": "medium", "summary": "auto"}.

Altogether, the docs give a complete example of getting a reasoning summary with liteLLM:

response = litellm.completion(
    model="openai/responses/gpt-5-mini",
    messages=[{"role": "user", "content": "What is the capital of France?"}],
    reasoning_effort={"effort": "high", "summary": "auto"}  # "auto", "detailed", or "concise" (not all supported by all models)
)

In ADK I believe you could try creating the model in the following way.

model = LiteLlm(
    model="openai/responses/gpt-5.1",
    reasoning_effort={"effort": "medium", "summary": "auto"}
)

Please let me know if this works, or if you still have difficulty accessing the reasoning content.

jazhang00 avatar Jun 24 '26 16:06 jazhang00

This issue has been automatically marked as stale because it has not had recent activity for 7 days after a maintainer requested clarification. It will be closed if no further activity occurs within 7 days.

adk-bot avatar Jul 02 '26 07:07 adk-bot

This has been automatically closed because it has been marked as stale for over 7 days.

adk-bot avatar Jul 09 '26 07:07 adk-bot