mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 21:05:40 +07:00
[PR #810] [CLOSED] serve: accept json_schema roots that are unions of object schemas #2845
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#2845
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/810
Author: @canfieldjuan
Created: 10/4/2026
Status: ❌ Closed
Base:
main← Head:fix/json-schema-root-object-unions📝 Commits (1)
3150fc4serve: accept json_schema roots that are unions of object schemas📊 Changes
3 files changed (+80 additions, -3 deletions)
View changed files
📝
docs/DETAILS.md(+4 -1)📝
serve/structured.py(+32 -2)📝
serve/test_structured.py(+44 -0)📄 Description
Problem
response_format: {"type":"json_schema", ...}returns 400response_format schema must have type object at its rootfor a root
anyOf/oneOfof object schemas, for example:llama.cpp's server accepts this schema (it compiles it to a grammar), so apps written against it send it. On Strata
those apps fail, although every answer the schema allows is one JSON object.
Change
serve/structured.py:_only_objects()decides whether a root can only ever be a JSON object:"type":"object";anyOf/oneOfwhose branches all qualify;allOfwith a qualifying member;$refto one of these. A$refcycle never qualifies.prepare_formatuses it instead of the literaltype == "object"check, so two things stay true: the "returnexactly one JSON object" directive, and the object check when
jsonschemais not installed. A root that alsoallows an array, string, number, boolean or null is still refused with a 400 before the engine loads. That
includes
"type":["object","null"]and a schema without atype.docs/DETAILS.md: the root rule.Tests
serve/test_structured.pyhas two new tests:anyOf,oneOf,allOf,$ref, nested) are accepted, and a non-object answer to them is still refused (502);python -m unittest serve.test_structured: 10 OK.jsonschema: 2 skipped, as before.jsonschema4.x installed: 0 skipped.python -m unittest serve.test_server serve.test_security serve.test_lifecycle serve.test_detok serve.test_mcp serve.test_monitor serve.test_winjob:214 OK (7 skipped). Run on Linux (Ubuntu 24.04, Python 3.13) against current
main.Also checked end to end: a document-summarizer app that sends a schema like the one above now gets its answers from
Strata instead of a 400.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.