Skip to content

fix: support unconstrained array item schemas - #2378

Open
tuanzirwar wants to merge 2 commits into
abetlen:mainfrom
tuanzirwar:codex/support-unconstrained-array-item-schemas
Open

tuanzirwar wants to merge 2 commits into
abetlen:mainfrom
tuanzirwar:codex/support-unconstrained-array-item-schemas

Conversation

@tuanzirwar

@tuanzirwar tuanzirwar commented Oct 1, 2026 •

Copy link
Copy Markdown

LlamaGrammar.from_json_schema() raises KeyError for {"type": "array", "items": {}}, including the schema generated by Pydantic for list[Any]. Empty schemas in other positions are also incorrectly restricted to objects.

Preserve empty items when there is no prefixItems fallback and compile an empty schema as the existing unrestricted JSON value rule. Keep typed arrays and closed tuples using prefixItems with items: false working. Add regression and compatibility tests and an Unreleased changelog entry.

Validation: 8 grammar tests pass; all Python source/tests pass Ruff and formatting checks. Three new regressions fail on the original code. With the same-version official 0.3.36 CPU library and a tiny GGUF model, the native grammar sampler accepts number/string/boolean/null/object/array elements, and real grammar-constrained CPU inference returns []. Large models, GPU backends, and the full server suite were not exercised.

AI-assisted implementation. The Unreleased changelog entry references #2378.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant