Repository navigation
[Bug]: ollama-native fails turns where a model returns several tool calls at the same function index #6857
Description
Client or integration
Codex CLI
Area
Provider adapter
Summary
ollama-native fails every turn in which an Ollama Cloud model returns more than one tool call in a single frame, if the calls share a function.index. ollama-cloud/mistral-large-4 does this: each call has its own id, but function.index is 0 for all of them. nativeMessageEvents in src/adapters/ollama-native.ts uses the index as the call's identity (index:${index}). The second call therefore matches the first one's key and the stream fails with:
Provider stream error: ollama-native response changed a tool-call id for an existing index
If the two calls have different function names, the same collision throws reused a tool-call index for another function instead.
There is a second guard behind the first one. The generated Codex catalog marks this model supports_parallel_tool_calls: false, so the request carries parallelToolCalls: false. Once the two calls are recognized as distinct, the adapter throws emitted parallel tool calls while parallelToolCalls:false was requested. Either way the turn fails, and the user gets no answer.
Reproduction
- Route Codex to
ollama-cloud/mistral-large-4through opencodex (devat93ed1a40b, also onmain/ 2.81.0). - Ask for something that needs two independent tool calls, for example reading two files.
- Codex retries 5 times, then fails with the error above.
The raw native stream for that turn (POST https://ollama.com/api/chat, stream: true, with tools) has both calls in one frame:
{"message":{"role":"assistant","content":"","tool_calls":[
{"id":"PpZ8JqRmm","function":{"index":0,"name":"read_file","arguments":{"path":"/etc/hostname"}}},
{"id":"DDe4wZqkx","function":{"index":0,"name":"read_file","arguments":{"path":"/etc/os-release"}}}]},"done":false}
{"message":{"role":"assistant","content":""},"done":true,"done_reason":"tool_calls"}Version
dev at 93ed1a40b (2026-10-10); also present in the installed 2.72.0 and in main 2.81.0.
Operating system
Ubuntu 24.04 (Linux 6.17, aarch64)
Provider and model
Ollama Cloud (ollama-native) / mistral-large-4
Logs or error output
ERROR: Reconnecting... 5/5
ERROR: stream disconnected before completion: Provider stream error: ollama-native response changed a tool-call id for an existing indexScreenshots and supporting files
Not applicable. The frame above is the whole evidence; the linked PR inlines it as a regression fixture.
Redacted configuration
{ "model": "ollama-cloud/mistral-large-4", "supports_parallel_tool_calls": false }Checks
- I searched existing issues and documentation.
- I removed secrets, tokens, account details, request credentials, and personal data.
Activity
lidge-jun commentedon Oct 10, 2026
Fixed on
devby #6858 (squashaa95a485b7). ollama-native now keys response tool calls by their native id before falling back to the index, so several calls at the same function index no longer collide.