Skip to content

structured_outputs: extend XML type coercion to handle oneOf/anyOf/allOf composition - #1233

Open
schauhan54 wants to merge 5 commits into
NVIDIA-NeMo:mainfrom
schauhan54:fix/complex-schema-support
Open

schauhan54 wants to merge 5 commits into
NVIDIA-NeMo:mainfrom
schauhan54:fix/complex-schema-support

Conversation

@schauhan54

Copy link
Copy Markdown

Summary

Extends PR #1103 with two additional fixes for XML tasks that use oneOf/anyOf/allOf composition in their schemas:

  1. coerce_xml_types: now recurses into oneOf/anyOf branches (tries each branch, picks the first where coercion + validation succeeds) and allOf branches (coerces cumulatively). Without this, XML string values inside composition schemas stay as strings and fail validation even when the output is correct.

  2. strictify_schema: now recurses into allOf branches (so nested oneOf/anyOf get strictified) but strips additionalProperties from 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_types bails early with if "type" not in schema: return data when it encounters a composition node (oneOf/anyOf/allOf). This left XML string values uncoerced inside composition branches.

Failure breakdown (20 tasks before this fix):

Root cause Count
oneOf/anyOf branch mismatch (strings not coerced) 5
Enum validation fails (string vs enum inside composition) 4
Array unwrapping fails inside composition 4
Number/integer/boolean coercion fails 5
additionalProperties cross-branch rejection in allOf 2

After this fix: 100/100 tasks pass with syntax_reward=1.0.

Test plan

  • All 12 existing tests pass (including test_verify_json_with_allof_does_not_overstrictify_branches)
  • 100/100 XML delivery tasks validated through evaluate_structured_output_response
  • Review: does the oneOf/anyOf try-each-branch approach in coerce_xml_types handle edge cases correctly?

🤖 Generated with Claude Code

vincenth777 and others added 5 commits April 20, 2026 21:40
  - 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>
@copy-pr-bot

copy-pr-bot Bot commented May 5, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Jul 17, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer labels Oct 20, 2026

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

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer sla:triage-overdue Review assignment is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants