Only the first request is answered when using ollama model.
I try to build a simple agent using ollama model, here is my code:
from google.adk.agents import LlmAgent
from google.adk.models.lite_llm import LiteLlm
# 创建使用Ollama Gemma模型的代理
root_agent = LlmAgent(
model=LiteLlm(model="ollama/gemma3"),
name="root_agent",
description=("task agent"),
instruction=("You are a helpful assistant that can help with tasks and questions."),
)
I successfully executed the code, but it looks like only the first response was answered.
web page:
terminal log:
LLM Request:
-----------------------------------------------------------
System Instruction:
You are a helpful assistant that can help with tasks and questions.
You are an agent. Your internal name is "root_agent".
The description about you is "task agent"
-----------------------------------------------------------
Contents:
{"parts":[{"text":"What is 18 plus 5"}],"role":"user"}
{"parts":[{"text":"18 plus 5 is 23."}],"role":"model"}
{"parts":[{"text":"What is 20 plus 10"}],"role":"user"}
{"parts":[{"text":"Okay, I understand. I'm ready for your next task!"}],"role":"model"}
{"parts":[{"text":"What is 20 plus 10"}],"role":"user"}
{"parts":[{"text":"Okay, great! Let's move on to the next task."}],"role":"model"}
{"parts":[{"text":"hello"}],"role":"user"}
{"parts":[{"text":"Okay, great! Let’s move on to the next task."}],"role":"model"}
{"parts":[{"text":"What color are bananas"}],"role":"user"}
-----------------------------------------------------------
Functions:
-----------------------------------------------------------
I get the same situation, and after some work, found all message sent by the prompt, not the message field in openai compatible api result this。
hi team, supporting this issue. i also tried to reproduce this error.
i would appreciate an explanation of why this is the case.
there is a trick to prevent this.
model=LiteLlm("openai/qwen2.5:32b",base_url="http://localhost:11434/v1"),
use openai provider ,but specific the ollama base_url, and you need fill the OPENAI_API_KEY env as well.
@zhiheng-yu @me-tusharchandra
hi @lyfuci, can you share your complete code? if possible for model="ollama/gemma3:1b"
okay so @lyfuci, @zhiheng-yu, using ollama_chat solves the problem over ollama.
precisely: model=LiteLlm(model="ollama_chat/gemma3:1b")
to understand the behaviour differences between both please head over 'venv/lib/python3.13/site-packages/litellm/main.py'
@admins please close this issue, thanks!
@me-tusharchandra Thanks! It works.
okay so @lyfuci, @zhiheng-yu, using ollama_chat solves the problem over ollama.
precisely: model=LiteLlm(model="ollama_chat/gemma3:1b")
to understand the behaviour differences between both please head over 'venv/lib/python3.13/site-packages/litellm/main.py'
@admins please close this issue, thanks!
@me-tusharchandra thanks!!
okay so @lyfuci, @zhiheng-yu, using ollama_chat solves the problem over ollama.
precisely: model=LiteLlm(model="ollama_chat/gemma3:1b")
to understand the behaviour differences between both please head over 'venv/lib/python3.13/site-packages/litellm/main.py'
@admins please close this issue, thanks!