Skip to content

Fix Finder / Troubleshooting

llama.cpp JSON schema not working: check the endpoint and required fields

When llama.cpp returns valid JSON with missing required fields, check the actual endpoint, serialized request body and original schema. A JSON parser can accept an answer that still violates your application contract.

The retained evidence covers two different problems: a Chat API schema envelope sent to native /completion, and a mixed properties/oneOf schema whose required action field was not enforced. Start with the endpoint check below.

Check a schema request locally

Free browser-local debugger

Why did my AI response fail?

Check an empty answer, context overflow, or a schema sent to the wrong endpoint. Inspect a proposed change, then verify it against your original task.

Pasted data stays in this tab. This debugger makes no API calls, executes no tools, and saves no inputs. Diagnosis does not prove a correction works on your setup.

Try a retained example or paste your own JSON below.

Up to 40,000 characters per box. Use the final assembled Chat Completions JSON body, not a streaming fragment, cURL command, or HTTP headers. Native /completion requests are supported for schema-envelope checks. Leave keys and account details out.

Context counts and local file import

Use measured runtime counts, including template, history and tools. This tool does not estimate tokens from character count or predict memory fit.

Loading local debugger…

Evidence and supported scope

Rules reuse the ten completed pilot repairs listed below. Model tests used pinned llama.cpp 0.6.0 b11429 and Qwen3-4B Q4_K_M on one Mac. The first four have separate-agent reruns on that Mac; the remaining six have same-agent repeats. No second-machine, human reproduction, or universal compatibility is claimed. Example previews replay retained data; they run no new model inference.

Malformed JSON, conflicting schemas and unsupported response shapes remain unresolved. A parseable response can still contain wrong facts. Schema-envelope proposals preserve the supplied schema; they do not establish general schema support.

Check the schema location for the actual route

Repair 010 sent the required schema inside response_format to native POST /completion. The completed response contained the correct inner facts, id: 17 and text: ALPHA, but omitted the required kingy_record wrapper.

Moving the unchanged schema to native top-level json_schema restored the exact contract:

{"kingy_record":{"id":17,"text":"ALPHA"}}

The debugger offers that envelope change only when llama.cpp and the native /completion route are specified and it finds a supported object schema. It preserves the prompt and other request values. Conflicting schema locations produce no proposed request. The proposal is not executed.

Keep Chat API request formats with their corresponding chat endpoint. Repair 010 does not establish that all response_format requests are ignored, or that moving a schema is appropriate for another runtime.

Inspect the exact request-envelope repair · Server documentation for the tested build.

A converter limitation needs a different correction

Repair 004 used the native schema field already. Its mixed schema produced a completed object with location but no required action. The retained grammar made the action key optional.

For that specific contract, expressing each oneOf alternative as a complete, disjoint object restored the action field. The original application schema stayed the validator. Extra fields and empty action arrays remained permitted where the original contract allowed them.

This was a bounded schema rewrite, not a general normalizer. The browser debugger links to the evidence; it does not rewrite arbitrary oneOf schemas or establish full Draft 7 support. The pinned grammar guide documents mixed-keyword limitations and silently skipped unsupported features.

Inspect repair 004 and its semantic checks · Pinned grammar guide and limitations.

Validate syntax, contract and source values separately

  1. Keep the original response and request. A truncated response needs a completion check before schema diagnosis.
  2. Parse the output. A single enclosing Markdown fence may be a formatting problem, covered by the bounded fence repair.
  3. Validate against the original application schema. Required fields must remain required.
  4. Check the values against the original task and source. Correct syntax and schema do not prove factual accuracy.

After changing a request envelope or decoder schema, repeat the unchanged task, require complete termination, and validate the original contract. Keep failed attempts alongside the corrected result.

What this evidence covers

These model tests were qualified October 15–16, 2026, using llama.cpp 0.6.0 build 11429 and Qwen3-4B Q4_K_M on one M4 Pro Mac with 24 GiB unified memory. Repairs 001–004 have separate-agent reruns on that Mac. Repairs 005–010 have same-agent repeats in fresh server processes. No second-machine or human reproduction is claimed.

This guide reuses those retained results. Loading an example runs no model. The debugger performs local static checks and cannot verify a proposed correction on your setup. Each linked repair retains its exact artifacts, failed attempts and applicability limits.

Open the full Fix Finder debugger · Browse all tested repairs

Guide published October 16, 2026. Repair measurements remain dated October 15–16, 2026.