Ollama Structured Output vs a JSON Tool: measured tool-call loss and invented values on a local model (2026)
There are two documented ways to get machine-readable output from a local Ollama model, and they look interchangeable. You can constrain the reply with format — or response_format on the OpenAI-compatible endpoint — so the decoder emits JSON that matches a schema. Or you can register a tool and let the model call it, with the tool’s result being the JSON you wanted. The practical failure comes from doing both at once, which is a natural thing to do: keep the tools registered, and add format when a structured summary is due. On a self-hosted server the constraint wins and the tool call disappears. Nothing reports an error. The response is HTTP 200, done_reason is stop, tool_calls is absent, and content holds a schema-valid object in which the model has invented the values the tool was supposed to fetch. ...