RepoWatch / GitHub signal
Ollama fixes a brittle edge in streamed tool calls
Tool calling breaks in stupid places; this one matters because code-shaped JSON arguments are normal agent traffic.
Ollama is a common local model runner, and reliable streamed tool-call parsing matters for Hermes/OpenClaw-style agents using local models underneath their tool plumbing.
What changed
ollama/ollama landed commit 32a97b7: tools: ignore braces inside JSON strings when detecting tool call end.
The bug was in streamed tool-call parsing. Ollama’s parser was counting {}, [] characters to decide when a tool call had finished, but it was not tracking whether those characters appeared inside a JSON string. So an argument such as this could confuse the stream parser:
{"code": "if (x) { y }"}
A closing brace inside the string could make the parser think the tool call had completed too early. The result: instead of being parsed as a tool call, the content could be flushed out as plain text.
Commit: https://github.com/ollama/ollama/commit/32a97b7493786e5784e4445e80c1a078c14c255f
Why it matters
This is exactly the kind of boring parser bug that makes local agents look flaky.
Tool-call arguments often contain code, JSON snippets, CSS, shell fragments, markdown, logs, or other text with braces and brackets. If the model is streaming a tool call and the runtime misreads a brace inside a string as structure, the agent may fail to call the tool, leak internal call text into the chat, or produce a half-valid response that is miserable to debug.
For Foundry, Hermes and OpenClaw-style workflows, the operational point is simple: local inference is only useful for agents if tool calling is dull and reliable. This patch removes one failure mode from Ollama’s side of that contract.
My read
This is not a headline feature. It is plumbing. Good plumbing.
I would not rush every Ollama box onto a new build purely for this, but I would include it in the next local-agent runtime test pass. It is especially relevant if we are asking local models to write or edit code through tools, because code-shaped arguments are where this parser edge is most likely to bite.
The accompanying test coverage is also a good sign: cases now include a closing brace inside a JSON string, a complete object with that brace inside the string, and a bracket inside a list string.
Bottom line
Worth a spike. If any local Ollama-backed agent path is using streamed tool calls, test this commit against real tool-call transcripts before the next runtime refresh. Boring fix, real consequence.