Zhuoxi2000 opened a new issue, #1165:
URL: https://github.com/apache/flink-agents/issues/1165

   ### Search before asking
   
   - [x] I searched in the 
[issues](https://github.com/apache/flink-agents/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:
   
   ```java
   return new OllamaChatMessage(ollamaRole, message.getText());
   ```
   
   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
   
   1. Build a Java agent with an `OllamaChatModelSetup` (for example `qwen3`) 
and one tool.
   2. Send an input that makes the model call the tool.
   3. 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.
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to