fix(openai): require nested strict schema fields - #441
Open
Seth Juarez (sethjuarez) wants to merge 1 commit into
Open
fix(openai): require nested strict schema fields#441Seth Juarez (sethjuarez) wants to merge 1 commit into
Seth Juarez (sethjuarez) wants to merge 1 commit into
Conversation
Align the recursive strict JSON Schema contract with OpenAI by marking every nested object property required while representing Prompty optional fields as nullable. Add a shared wire vector, cross-runtime harness coverage, and a live nested structured-output check. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens Prompty’s OpenAI Structured Outputs “strict” wire contract so that every object property is listed in required recursively, while Prompty-optional fields are modeled as nullable unions (e.g., type: ["string", "null"]). It updates both the normative spec/docs and the shared wire vectors, and adjusts harnesses/tests so nested schemas are exercised end-to-end.
Changes:
- Updated the wire-format specification/docs to define strict-mode recursive
requiredbehavior and nullable modeling for optional fields. - Added a new canonical wire vector (
structured_output_nested_optional) that asserts nested optional handling in strict mode. - Updated TypeScript vector harness loading to use generated
Property.load(...)(preserving nested property shapes) and updated Rust wire/tests to require nested properties under strict mode.
Show a summary per file
| File | Description |
|---|---|
| web/src/content/docs/specification/wire-format.mdx | Documents strict-mode recursive required + nullable optionals in schema conversion. |
| spec/vectors/wire/wire_vectors.json | Adds canonical nested-optional structured output wire vector + expected strict schema. |
| spec/spec.md | Updates normative spec text/pseudocode for strict schema generation rules. |
| runtime/typescript/packages/core/tests/spec-vectors.test.ts | Uses Property.load so vectors preserve generated nested property subtypes. |
| runtime/rust/prompty-openai/tests/wire_vectors.rs | Exercises the new vector and updates strict nested required assertions. |
| runtime/rust/prompty-openai/tests/integration.rs | Updates ignored live test to validate nested optional strict output is nullable + required. |
| runtime/rust/prompty-openai/src/wire.rs | Ensures strict mode includes nested properties in required arrays (recursive behavior). |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Lite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
requiredRuntime audit
requiredgenerationmain2355dbe1,da5a3f6e)Verification
cargo test -p prompty-openaicargo fmt --all -- --checkuv run pytest tests/test_spec_vectors.py tests/test_executor.py tests/test_structured.py -q(219 passed, 17 skipped)npm run test --workspace @prompty/core -- spec-vectors.test.ts(140 passed, 17 skipped)npm run test --workspace @prompty/openai(91 passed, 18 skipped)npm run lint --workspace @prompty/coreSpecVectorWireTestsassembly run (25 passed)test_structured_outputE2E: accepted the nested strict schema and returned{"style":{"border":null,"color":"blue"}}response_format.json_schema.schema.properties.style.required(expected 2 keys, got 1), then the restored fix passes all 695 testsThe live Java negative check also reproduced OpenAI's nested-schema rejection verbatim:
In context=('properties', 'address'), 'required' is required to be supplied and to be an array including every key in properties. Missing 'postcode'.The contract matches OpenAI's Structured Outputs guidance: all fields must be required, optional fields are modeled with
null, and the rule applies to nested object schemas.