Tool calls are not properly returned when chat() is called with stream=True #141

Closed
opened 2026-02-15 16:28:15 -05:00 by yindo · 4 comments
Owner

Originally created by @ggozad on GitHub (Sep 12, 2024).

Originally assigned to: @ParthSareen on GitHub.

I have been working on integrating Ollama tools with oterm.
When making a call to AsyncClient.chat() with tools defined and stream=True the response gives the tools to be called and params in the content attribute of the json response. For example:

{'role': 'assistant', 'content': '{"name": "get_current_location", "parameters": {}}'}

Same call with stream=False has, as it should, an empty content and the tools inside the tool_calls attribute.

Originally created by @ggozad on GitHub (Sep 12, 2024). Originally assigned to: @ParthSareen on GitHub. I have been working on integrating Ollama tools with [oterm](https://github.com/ggozad/oterm). When making a call to `AsyncClient.chat()` with `tools` defined and `stream=True` the response gives the tools to be called and params in the `content` attribute of the json response. For example: ```json {'role': 'assistant', 'content': '{"name": "get_current_location", "parameters": {}}'} ``` Same call with `stream=False` has, as it should, an empty `content` and the tools inside the `tool_calls` attribute.
yindo closed this issue 2026-02-15 16:28:15 -05:00
Author
Owner

@cpsievert commented on GitHub (Sep 27, 2024):

I'm also experiencing this. And to add a bit more context, there is no information in the response chunks to indicate that a tool call was chosen

{'model': 'mistral', 'created_at': '2024-09-27T15:55:56.521147Z', 'message': {'role': 'assistant', 'content': '[{"'}, 'done': False}
{'model': 'mistral', 'created_at': '2024-09-27T15:55:56.551562Z', 'message': {'role': 'assistant', 'content': 'name'}, 'done': False}
{'model': 'mistral', 'created_at': '2024-09-27T15:55:56.583256Z', 'message': {'role': 'assistant', 'content': '":"'}, 'done': False}
...
@cpsievert commented on GitHub (Sep 27, 2024): I'm also experiencing this. And to add a bit more context, there is no information in the response chunks to indicate that a tool call was chosen ``` {'model': 'mistral', 'created_at': '2024-09-27T15:55:56.521147Z', 'message': {'role': 'assistant', 'content': '[{"'}, 'done': False} {'model': 'mistral', 'created_at': '2024-09-27T15:55:56.551562Z', 'message': {'role': 'assistant', 'content': 'name'}, 'done': False} {'model': 'mistral', 'created_at': '2024-09-27T15:55:56.583256Z', 'message': {'role': 'assistant', 'content': '":"'}, 'done': False} ... ```
Author
Owner

@petri commented on GitHub (Nov 24, 2024):

Related: https://github.com/ollama/ollama/issues/5796, "Streaming for tool calls is unsupported"

@petri commented on GitHub (Nov 24, 2024): Related: https://github.com/ollama/ollama/issues/5796, "Streaming for tool calls is unsupported"
Author
Owner

@ParthSareen commented on GitHub (Nov 26, 2024):

Coming soon!!! 🥳

@ParthSareen commented on GitHub (Nov 26, 2024): Coming soon!!! 🥳
Author
Owner

@ParthSareen commented on GitHub (Nov 27, 2024):

Fixed! https://github.com/ollama/ollama/releases/tag/v0.4.6

@ParthSareen commented on GitHub (Nov 27, 2024): Fixed! https://github.com/ollama/ollama/releases/tag/v0.4.6
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ollama/ollama-python#141