What this thread does
Do first: Upgrade Ollama to v0.40.18 (as of November 2026).
Symptom
Structured outputs appear to be ignored for MLX models
ishermandom reported natural-language output instead of schema-conforming JSON on macOS with Ollama 0.30.6, despite supplying format to /api/chat. Reporter: ishermandom. Other issue participants include thebrickmaster626-bit and trebor; their comments discuss the report or proposed changes.
Cause
The MLX runner accepted the format field but did not constrain sampling. The merged implementation uses xgrammar masks so generated tokens follow the requested structure. In the November release, the client converts the public format into an internal structural tag before handing it to the grammar engine. Merged change.
Fix
1. Upgrade Ollama to v0.40.18 (as of November 2026). 2. Send a JSON Schema object in the public API’s format field, or use format: "json" for a JSON object. The current MLX client translates these API values internally; clients should keep using the public API values.
Sources: fix PR; v0.40.18 implementation.
Fixed in
Fixed in v0.33.1 (released 2026-08-26), the first stable carrying release. PR #17929 was merged on 2026-08-26.
If it still fails
- The original fix implements a JSON Schema subset and describes a missing grammar library as an explicit structured-request failure. Multi-branch
allOfcan lose constraints. Beforev0.33.1, the MLX runner did not enforce the format field. The November client still translates public JSON formats into grammar constraints.
Not for: MLX stop sequences being ignored; see ollama-mlx-stop-sequence-ignored.
Sources
- Structured outputs appear to be ignored for MLX models, ishermandom, opened 2026-06-06; closed as completed on 2026-08-26: "Both models should produce output conforming to the supplied schema."
- mlxrunner: add structured output support, jessegross, merged 2026-08-26 (closed).
- v0.33.1, published 2026-08-26.
- v0.40.18, published 2026-11-24.
- Release ancestry comparison, read 2026-11-24; merge commit is behind the release tag.
- Implementation at v0.40.18, read 2026-11-24.
- Issue comment by thebrickmaster626-bit, thebrickmaster626-bit, 2026-06-06; parent issue closed as completed on 2026-08-26.
- Issue comment by trebor, trebor, 2026-06-10; parent issue closed as completed on 2026-08-26.
Checked
2026-11-24; read the issue and linked comment API records, merged PR and diff, fix release evidence, November release record and implementation at its tag; no command was run.
Started from a post by @ishermandom, packaged by the editor. Original post