You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: reasoning deltas combined with newlines in litellm #5645
Describe the Bug:
In the LiteLLM adapter model, reasoning parts are combined with a newline injection (_NEW_LINE.join(text for text in reasoning_texts if text)). When using models/providers that stream reasoning in delta fragments (such as vLLM-style reasoning chunks), this mutates the original stream by inserting extra newline separators between the chunks. Consequently, the reconstructed reasoning differs from the exact output returned by the provider.
Steps to Reproduce:
Please provide a numbered list of steps to reproduce the behavior:
Initialize an ADK Agent using the LiteLlm adapter.
Connect to a model that generates streamed reasoning in delta fragments (eg. vllm deployed model with qwen).
Execute a turn and inspect the streamed reasoning chunks and the final generated reasoning message.
Observe that the reasoning string contains unexpected extra newlines that were not present in the native chunks.
Expected Behavior:
The reasoning text should be preserved exactly as streamed by concatenating fragments directly (i.e. "".join(...)), without artificially adding newlines, so that the stream represents the provider's native output precisely.
Observed Behavior:
Refer to PR #4952 implementation and the proposed fix addressing this issue.
Environment Details:
ADK Library Version (pip show google-adk): latest
Desktop OS: macOS
Python Version (python -V): Python 3.11+
Model Information:
Are you using LiteLLM: Yes
Which model is being used: Any model streaming reasoning with vllm (e.g. qwen3.5)
Could you please share a minimal reproducible code snippet so we can investigate this issue? Additionally, let us know if you have observed this problem across other models in LiteLLM and how the results compare if you test it using the Gemini() model class. Also if you are not already using google-adk==1.33.0, we recommend upgrading and testing with this version. Sharing this information will help us analyze this issue better.
I do not currently have credentials available for the native Gemini() path, so unfortunately, I cannot run a live comparison. My understanding from the code is that this issue is specific to the LiteLLM adapter path: the affected logic is _content_to_message_param() in google/adk/models/lite_llm.py, where ADK thought parts are serialized back into LiteLLM reasoning_content.
This matters for providers such as vLLM, which can stream reasoning output as delta chunks. With vLLM reasoning enabled, streamed chat completion chunks may contain reasoning deltas in delta.reasoning or delta.reasoning_content. ADK stores those streamed reasoning deltas as separate thought parts, and later _content_to_message_param() serializes them back into LiteLLM history. If newline separators are inserted during that serialization, provider-emitted reasoning text can be changed before it is sent back on the next turn.
Minimal local reproduction of the adapter behavior:
Activity
lorenzbaraldi commentedon May 11, 2026
I previously opened a PR addressing this issue in google/adk-python PR #4952. Let me know if you have any feedback or suggestions.
llalitkumarrr commentedon May 11, 2026
Hello @lorenzbaraldi ,
Could you please share a minimal reproducible code snippet so we can investigate this issue? Additionally, let us know if you have observed this problem across other models in
LiteLLMand how the results compare if you test it using theGemini()model class. Also if you are not already usinggoogle-adk==1.33.0, we recommend upgrading and testing with this version. Sharing this information will help us analyze this issue better.lorenzbaraldi commentedon May 11, 2026
I’m using
google-adk==1.33.0.I do not currently have credentials available for the native
Gemini()path, so unfortunately, I cannot run a live comparison. My understanding from the code is that this issue is specific to the LiteLLM adapter path: the affected logic is_content_to_message_param()ingoogle/adk/models/lite_llm.py, where ADK thought parts are serialized back into LiteLLMreasoning_content.This matters for providers such as vLLM, which can stream reasoning output as delta chunks. With vLLM reasoning enabled, streamed chat completion chunks may contain reasoning deltas in
delta.reasoningordelta.reasoning_content. ADK stores those streamed reasoning deltas as separate thought parts, and later_content_to_message_param()serializes them back into LiteLLM history. If newline separators are inserted during that serialization, provider-emitted reasoning text can be changed before it is sent back on the next turn.Minimal local reproduction of the adapter behavior:
Before this PR, this produces:
'Hel\nlo'Expected:
'Hello'lorenzbaraldi commentedon May 26, 2026
Hei @llalitkumarrr I just wanted to follow up on this issue. Do you have any news or feedback?
llalitkumarrr commentedon Jun 11, 2026
Hello @lorenzbaraldi ,
We apologies for the delay, the PR is under review and we will let you know if any additional information is required.
fix: Litellm preserve streamed reasoning deltas in LiteLLM adapter
fix: Litellm preserve streamed reasoning deltas in LiteLLM adapter