Repository navigation
structured_outputs: extend XML type coercion to handle oneOf/anyOf/allOf composition - #1233
Open
schauhan54 wants to merge 5 commits into
Open
schauhan54 wants to merge 5 commits into
schauhan54 wants to merge 5 commits into
Conversation
- strictify_schema: recurse into list items so object schemas nested inside
oneOf/anyOf/allOf branches get required + additionalProperties: false.
- coerce_xml_types: resolve $ref pointers against the top-level schema's
$defs via a new root_schema parameter (defaults to None for backward compat).
Signed-off-by: Vince Huang <vincehuang@mercor.com>
- strictify_schema: skip allOf branches (conjunctive merge would reject fields contributed by sibling branches) - coerce_xml_types: support nullable union types like ["integer","null"] (parity with CSV path); make root_schema required; use removeprefix - add tests: anyOf strictification, allOf composition regression guard, nullable XML coercion; extend oneOf test with second-branch case - add data/example_complex_schema.jsonl (5 toy rows) and an end-to-end smoke test that round-trips every row with hand-crafted gold outputs Signed-off-by: Vince Huang <vincehuang@mercor.com>
…composition branches coerce_xml_types now recurses into oneOf/anyOf branches (try each, pick first valid coercion) and allOf branches (coerce cumulatively). Without this, XML values inside composition schemas stay as strings and fail validation even when the output is correct. strictify_schema now recurses into allOf branches (so nested oneOf/anyOf get strictified) but strips additionalProperties from each branch to prevent cross-branch rejection. Validated against 100 XML tasks from the structured-outputs delivery — all get syntax_reward=1.0. Existing test suite (12 tests) passes unchanged. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Sep 8, 2026
This was referenced Oct 22, 2026
This branch has not been deployed
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
Extends PR #1103 with two additional fixes for XML tasks that use
oneOf/anyOf/allOfcomposition in their schemas:coerce_xml_types: now recurses intooneOf/anyOfbranches (tries each branch, picks the first where coercion + validation succeeds) andallOfbranches (coerces cumulatively). Without this, XML string values inside composition schemas stay as strings and fail validation even when the output is correct.strictify_schema: now recurses intoallOfbranches (so nestedoneOf/anyOfget strictified) but stripsadditionalPropertiesfrom each branch to prevent cross-branch rejection.Motivation
When validating 100 XML structured-output tasks from the Mercor delivery dataset against the Gym resource server (with PR #1103), 20 tasks failed because
coerce_xml_typesbails early withif "type" not in schema: return datawhen it encounters a composition node (oneOf/anyOf/allOf). This left XML string values uncoerced inside composition branches.Failure breakdown (20 tasks before this fix):
oneOf/anyOfbranch mismatch (strings not coerced)additionalPropertiescross-branch rejection inallOfAfter this fix: 100/100 tasks pass with
syntax_reward=1.0.Test plan
test_verify_json_with_allof_does_not_overstrictify_branches)evaluate_structured_output_responseoneOf/anyOftry-each-branch approach incoerce_xml_typeshandle edge cases correctly?🤖 Generated with Claude Code