﻿# Which JSON schema placements should you test with llama.cpp b12229?

Send both documented request shapes and verify the resulting instance against the schema using an independent validator.

Author: Retrivium team
Updated: 2026-11-10
Canonical URL: https://retrivium.ai/journal/news-llamacpp-json-schema-placement-compatibility/
Language: en

The b12229 pre-release changes how the OpenAI-compatible chat endpoint reads a JSON schema. The release notes say the nested wrapper was recognized before the fix, while a schema sent directly under response_format could be ignored. A client can test this request contract without changing models.

## Reproduce the two envelopes

Keep response_format.type set to json_schema. In one request supply the schema through the nested json_schema object, and in the other provide it directly as the schema field under response_format. Record the actual transmitted JSON after any gateway or SDK transforms it. That is what the server reads.

## Make the constraint observable

Pick a schema with a required field whose allowed values form a small enumeration. Use a prompt that would plausibly produce other values without enforcement. A request can return valid JSON while violating an enumeration or omitting a required field. Parseability and schema conformance need separate assertions.

## Classify incomplete responses

Allow enough output tokens to produce a complete instance. Record stop reasons, transport errors and validation failures separately. A truncated generation tells little about schema selection. If you stream responses, validate the assembled content, and keep intermediate chunk handling as an independent client test.

## Keep one legacy fixture

Include a nested-wrapper case that already worked on your deployed revision, plus the direct field that previously exposed the problem. Test each supported gateway configuration rather than assuming it forwards unknown fields unchanged. This identifies regressions where the client and server individually appear healthy.

## Choose an upgrade criterion

The passing evidence is a complete conforming instance for both request shapes on the pinned build. Retain the application-side validator for unsupported keywords and downstream consumers. The change addresses placement, while support for JSON Schema features still follows the server’s actual conversion behavior.

## Primary sources

- [llama.cpp b12229](https://github.com/ggml-org/llama.cpp/releases/tag/b12229)
- [Upstream implementation and review](https://github.com/ggml-org/llama.cpp/pull/28697)

## Related reading

- [Validate JSON Schema to GBNF conversion in llama.cpp](/journal/llama-cpp-json-schema-gbnf-validation/)
- [Provider structured output: testing JSON and schema conformance separately](/journal/provider-structured-output-conformance-tests/)
