
Ollama Tool Calls: Object vs String Arguments on Two API Surfaces
A coding agent works for an afternoon against Ollama’s native /api/chat. Then someone points the OpenAI SDK at http://localhost:11434/v1 to reuse an existing client, or a library switches endpoints underneath the agent. The first turn still works. The second turn is where the run dies, in one of two ways that look unrelated: the executor calls args["path"] and gets TypeError: string indices must be integers, not 'str', because the arguments arrived as a JSON string; or the client stores the native assistant message, sends it back to /v1/chat/completions, and gets HTTP 400 before a single token is generated. Both failures have the same cause: the two surfaces of the same server encode a tool call in incompatible ways. On Ollama 0.20.3, non-streaming, with qwen3:0.6b, POST /api/chat returned function.arguments as a JSON object. POST /v1/chat/completions, same model, same prompt, same tools array, returned the same call with function.arguments as a JSON string. Replaying either assistant message into the other endpoint was rejected with 400, each with its own parse error. ...
