mirror of
https://github.com/ollama/ollama.git
synced 2026-03-27 02:58:43 +07:00
Root cause: StreamConverter.Process() only incremented contentIndex when closing a thinking block if text content was present. When a model emitted thinking followed directly by a tool_use block (no text in between), thinkingDone was never set and contentIndex was not incremented, causing the tool_use content_block_start to reuse index 0. Clients expecting sequential indices would then fail to find the tool content block. Fix: In the tool call loop, close any open thinking block (thinkingStarted && !thinkingDone) and increment contentIndex before opening the tool_use block, mirroring the existing logic that closes an open text block. Fixes #14816