Skip to content

[Bug]: ollama-native fails turns where a model returns several tool calls at the same function index #6857

Closed

Description

@MarcTCruz

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

  1. Route Codex to ollama-cloud/mistral-large-4 through opencodex (dev at 93ed1a40b, also on main / 2.81.0).
  2. Ask for something that needs two independent tool calls, for example reading two files.
  3. 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 index

Screenshots 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

  1. added
    bugSomething isn't working
    providerProvider adapters, OpenAI-compat presets, upstream API quirks
    toolstool_calls, MCP, web-search / sidecar tools
    on Oct 9, 2026
  2. lidge-jun commented on Oct 10, 2026

    @lidge-jun
    Owner

    Fixed on dev by #6858 (squash aa95a485b7). 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingproviderProvider adapters, OpenAI-compat presets, upstream API quirkstoolstool_calls, MCP, web-search / sidecar tools

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions