Ollama 0.35 re-sorts JSON schema keys alphabetically on native chat path
In Ollama 0.35, models without a Go template, or with OLLAMA_GO_TEMPLATE=false, go through llamaServerChatResponseFormat(), which decodes the schema into a map[string]any and re-encodes keys in alphabetical order. Gemma 3 1B then returned the colour in the animal field while the JSON stayed valid and the request returned HTTP 200. The open fix is PR #18721.
- Schema is decoded into map[string]any, and Go writes map keys sorted
- With OLLAMA_GO_TEMPLATE=false, Gemma 3 1B put "blue" in alpha_animal
- On default settings four models, including two hf.co imports, kept declared order
- Fix PR #18721 passes the schema as json.RawMessage without decoding
Read next
Software