Back Home

GitHub Repo

Ollama Community Reports Tool Result Mismatch; Parallel Call Order May Change Answers

Ollama’s OpenAI-compatible endpoint was reported to pair tool results by message position, meaning correct call IDs may still fail to prevent results from being swapped. The community has proposed two fixes, neither merged yet; agents using parallel tool calls should validate result pairing.

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

The Ollama community reported a tool-call correctness issue on October 2: in the tested /v1/chat/completions path, swapping the message order of two tool results could cause the model to assign each result to the other call, even when each result retained the correct tool_call_id. The issue includes a minimal reproduction, and two fix proposals appeared on October 2 and 3. Issue report

The reporter demonstrated the issue with weather queries for Tokyo and Toronto: the two calls returned 5 and 22 degrees, respectively, and the answer was correct when results were returned in the original call order. Reversing only the result-message order changed the answer to 22 degrees for Tokyo and 5 degrees for Toronto. In tests with Ollama 0.35.1, gpt-oss:20b, temperature set to zero, and a fixed seed, the normal and swapped orderings were each run three times; the swapped ordering produced the same mismatch all three times. These are the reporter’s test results and do not establish that all models and deployments are affected. Reproduction details

The technical focus is message conversion and prompt rendering. The report says that after swapping the result IDs on the tested path, the rendered prompts remained byte-for-byte identical, supporting the assessment that call identity was not preserved through that stage. The October 3 fix proposal therefore suggests reordering complete, contiguous result groups by tool_call_id before converting OpenAI-format messages, and handling array-form text content to prevent IDs from being lost during conversion. At the time of review, the proposal remained open and unmerged. Fix proposal

For agent engineering, tool completion time may change input semantics. Ollama’s official documentation provides a parallel tool-calling workflow and lists tool support for compatible endpoints; if an application collects results in completion order, faster queries may appear first. Based on this report, that workflow could apply valid data to the wrong subject while still producing a well-formed answer. Tool-calling documentation, OpenAI compatibility documentation

Engineering teams can add regression tests that swap the order of results from the same batch and check whether answers remain consistent. Until a fix is verified, a temporary measure is to order results on the client side according to the original call order. Teams should also track the upstream merge and release version, and verify how the fix handles missing or duplicate IDs and incomplete result groups in the message flows their agents actually use.

Sources

  1. Ollama issue #18762:重排工具結果造成呼叫錯配
  2. Ollama PR #18767:依呼叫 ID 配對完整工具結果群組
  3. Ollama 工具呼叫文件
  4. Ollama OpenAI 相容性文件