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] Java Ollama connection drops assistant tool calls from the chat history #1165
I searched in the issues and found nothing similar.
Description
The Java OllamaChatModelConnection drops the tool calls of assistant messages when it turns the chat history into an Ollama request. convertToOllamaChatMessages builds every message from its role and text only:
After a tool round, the next request therefore carries the tool results but not the assistant turn that asked for them. The model sees results for calls it never made, and can respond by calling the same tool again.
The Python connection already forwards them as Message.ToolCall with the function name and arguments, so the same agent behaves differently on the same Ollama model depending on the language.
Expected: an assistant message's tool calls are sent as tool_calls, each with the function name and the arguments object, as in Python.
Actual: the assistant message is sent with empty content and no tool_calls.
How to reproduce
Build a Java agent with an OllamaChatModelSetup (for example qwen3) and one tool.
Send an input that makes the model call the tool.
Inspect the request for the second chat turn, for example through OllamaChatModelConnection.buildRequest: the assistant message has no tool_calls, and the tool message follows it.
Version and environment
main (eb35a38), Java OllamaChatModelConnection, ollama4j 1.1.5. The Python connection is not affected.
Activity