Diagram of one local model answering the same prompt on two Ollama endpoints: /api/chat returns function.arguments as an object whose Python type is dict, /v1/chat/completions returns the same call as a JSON string of type str, and replaying either assistant message into the other endpoint returns HTTP 400 with a distinct parse error.

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. ...

November 25, 2026 · 11 min · baeseokjae
Conceptual checklist for an empty tool-call response: HTTP 200 with empty content, then inspect the stop reason, then check the token usage. Raising the token cap is not a guaranteed fix.

Ollama Returns an Empty Response? Check the Token Limit

An agent sends a request with a tools array and a modest output cap. The server answers HTTP 200, the body parses, and the assistant message is empty: content is "", tool_calls is absent, and no error field explains it. The loop logs “model returned no content”, retries the identical request, and the next turn is empty in the same way. The operator starts suspecting the model, the quantisation or the chat template, because nothing in the client raised an exception. ...

November 8, 2026 · 11 min · baeseokjae