Back Home

GitHub Repo

Ollama Community Proposes Streaming Order Fix After Text-to-Tool Calls May Be Rejected by Responses Clients

A community report on October 5 says Ollama may reuse output indexes and omit a message completion event when it emits text before a tool call. The proposed fix includes regression tests but has not been merged or validated with actual model inference.

Mattruffoni · CC BY-SA 4.0 · Image source
zh-Hant

A streaming issue in Ollama’s API compatibility layer could disrupt local agent workflows. A report published on October 5 says that in versions 0.34.4 and 0.35.1, when /v1/responses emits assistant text and then a function call in the same turn, event indexes and the final result may be inconsistent. Clients that strictly validate the protocol may reject the response. This is a community report about a specific output pattern; it does not establish that all tool calls are affected. Issue report

The report identifies three parts of the mechanism: after a text message is created, output_index is not advanced, so the next function call reuses index 0; after the tool call is sent, completion handling skips the end event for the preceding text message; and when response.output is assembled, the function call is placed before the text, reversing the order declared in the stream. For consumers that track state by index, this may cause duplicate items or a mismatch in the final order, rather than merely a display-order difference. Event sequence and code path

Fix #18804, proposed the same day, completes any open text message before sending a function call, records that message, and advances the index. The author says the regression tests cover text followed by one or two tool calls, tool calls alone, index uniqueness, and consistency between IDs in events and the final array. The text-then-tool case failed before the fix, while the openai package tests passed afterward. However, these results come from the proposal author’s local tests and do not include actual model inference, the full repository test suite, or race-condition testing. Proposed fix

Ollama’s official documentation lists streaming and function calling as supported by the Responses endpoint. This case is therefore practically relevant to engineers connecting existing agent clients to local models: even when the endpoint and parameters are supported, the event lifecycle for mixed outputs still needs to be validated. Official compatibility documentation

Based on the mechanism described above, integration tests should include a “say something, then call a tool” scenario and check each output item’s index, completion event, and final order. Next, track upstream review, reproduction with actual inference, and the release that includes the fix. As of the time of review, the proposal remains open and should not be treated as evidence that an official release has fixed the issue.

Sources

  1. Ollama issue #18762:重排工具結果造成呼叫錯配
  2. Ollama PR #18767:依呼叫 ID 配對完整工具結果群組
  3. Ollama 工具呼叫文件
  4. Ollama OpenAI 相容性文件
  5. Gemma4: JSON schema format is not enforced when think:true answers directly without reasoning
  6. server: apply structured outputs in a single pass on thinking models
  7. Structured Outputs
  8. Ollama issue #18798:Responses 串流文字與函式呼叫順序問題
  9. Ollama PR #18804:在串流工具呼叫前完成文字項目