Repository navigation
inlineData image parts dropped when using /run endpoint #4975
Description
Bug Report: inlineData image parts dropped when using /run endpoint
Description
When sending a multimodal message (text + image) to the /run endpoint, the inlineData part is not forwarded to the underlying LLM. The image arrives at the ADK server correctly but is silently dropped before the LiteLLM call, resulting in the model receiving an empty images: [] array.
Environment
- ADK version: latest
- LiteLLM version: 1.82.4
- Model:
ollama_chat/ministral-3:8bvia Ollama - Ollama: local instance at
localhost:11434
Steps to Reproduce
- Start an ADK agent with a vision-capable Ollama model:
root_agent = Agent(
model=LiteLlm(model="ollama_chat/ministral-3:8b"),
name="assistant_agent",
...
)- Send a multimodal request to
/runwith both text and image parts:
{
"appName": "default",
"userId": "user",
"sessionId": "test",
"newMessage": {
"role": "user",
"parts": [
{"text": "What is in this image?"},
{
"inlineData": {
"mimeType": "image/png",
"data": "<base64-encoded-image>"
}
}
]
},
"streaming": false
}- Observe the model responds as if no image was provided.
Debug Evidence
With
import litellm
litellm._turn_on_debug()
it can be seen that the outgoing request to Ollama shows the image array is empty despite being present in the /run payload:
POST http://localhost:11434/api/chat
{
"messages": [
{"role": "user", "content": "What is in this image?", "images": []}
]
}
The inlineData base64 bytes are never populated into the images field.
Expected Behavior
The inlineData part from the /run payload should be converted and forwarded as base64 image data in the outgoing LLM request.
Actual Behavior
The images field is sent as an empty array []. The model responds as if no image was attached.
Additional Notes
The same model (ministral-3:8b) correctly processes images when called directly via the Ollama native UI or via the Ollama Python SDK, confirming the model itself supports vision. The issue is specific to ADK's message conversion layer between the /run API and the LiteLLM call.
Activity
weiguangli-io commentedon Mar 25, 2026
Root Cause
The bug is in
_flatten_ollama_content()atsrc/google/adk/models/lite_llm.py(lines 1154-1192), called by_normalize_ollama_chat_messages()(line 1195).When the model string starts with
ollama_chat,generate_content_async()normalizes the messages via_normalize_ollama_chat_messages()(line 2198). This calls_flatten_ollama_content(), which iterates the multipart content array and keeps only blocks withtype == "text"(line 1181-1184), silently dropping allimage_url/video_url/audio_urlblocks.So a well-formed multipart message:
[ {"type": "text", "text": "What is in this image?"}, {"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}} ]gets flattened to:
"What is in this image?"LiteLLM then receives a plain string (no multipart array), so it has nothing to populate Ollama's
imagesfield with →images: [].Proposed Fix
Modify
_flatten_ollama_content()to return the original multipart content list when it contains non-text media blocks (image_url,video_url,audio_url). LiteLLM's Ollama handler already knows how to convertimage_urlcontent blocks into Ollama's nativeimagesarray, so the flattening should only apply when the content is truly text-only:Happy to submit a PR if this approach looks good.
envyram commentedon Mar 25, 2026
Massively surprised no one has hit this issue so far - this is kind of a blocker.
envyram commentedon Mar 30, 2026
Hi - following up on this please
fix(models): preserve media blocks in _flatten_ollama_content
sanketpatil06 commentedon Apr 23, 2026
Hi @envyram , Thank you for reporting this. A Pull Request (#5296) has been submitted to address this issue and is currently being reviewed. While we review it, would you mind testing it on your side to confirm if it fixes the problem? Thanks
fix(models): preserve media blocks in _flatten_ollama_content
sanketpatil06 commentedon May 22, 2026
Hi @envyram , We are closing this issue because it has been inactive for while without the requested details. If you still need help, please feel free to reach out.
Thanks.
fix: preserve media blocks in ollama content flattening
fix: preserve media blocks in ollama content flattening
fix: preserve media blocks in ollama content flattening