Skip to content

fix: support root-referenced JSON Schema definitions in array outputs - #18802

Merged
n1ckoates merged 3 commits into
mainfrom
bugfix-6454-20260812180713431098
Aug 12, 2026
Merged

fix: support root-referenced JSON Schema definitions in array outputs#18802
n1ckoates merged 3 commits into
mainfrom
bugfix-6454-20260812180713431098

Conversation

@ai-sdk-factory

Copy link
Copy Markdown
Contributor

Background

OpenAI rejected array structured-output schemas containing root-relative definitions, preventing generateText, streamText, generateObject, and streamObject from returning validated arrays.

Root Cause

Both array schema wrappers moved the complete element schema, including definitions and $defs, under properties.elements.items while references still resolved from the generated root. Live HTTP 400 responses and failing regression tests confirmed the defect.

Summary

Array output wrappers now hoist definitions and $defs to the generated schema root while retaining the remaining element schema under items. A patch changeset was added.

Testing

Added regression coverage for definitions and $defs across Output.array() and the deprecated array output strategy.

End-to-end Validation

  • pnpm -C examples/ai-functions exec tsx --eval "$(git show HEAD:examples/ai-functions/src/reproduction/issue-6454-openai-array-definitions.ts)" exited successfully; all four live OpenAI array-output paths returned validated elements.

Related Issues

Fixes #6454

Closes #18795

ai-sdk-factory and others added 3 commits August 12, 2026 18:08
Co-authored-by: Nick Oates <58091943+n1ckoates@users.noreply.github.com>
Co-authored-by: jpkleemans <5700014+jpkleemans@users.noreply.github.com>
Co-authored-by: Nick Oates <58091943+n1ckoates@users.noreply.github.com>
Co-authored-by: jpkleemans <5700014+jpkleemans@users.noreply.github.com>
Co-authored-by: Nick Oates <58091943+n1ckoates@users.noreply.github.com>
@n1ckoates
n1ckoates merged commit 72ec74f into main Aug 12, 2026
60 checks passed
@n1ckoates
n1ckoates deleted the bugfix-6454-20260812180713431098 branch August 12, 2026 18:52
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.65 github npm
@ai-sdk/angular 3.0.65 github npm
@ai-sdk/code-mode 1.0.22 github npm
@ai-sdk/gateway 4.0.52 github npm
@ai-sdk/google 4.0.44 github npm
@ai-sdk/google-vertex 5.0.53 github npm
@ai-sdk/harness 1.0.71 github npm
@ai-sdk/harness-acp 1.0.8 github npm
@ai-sdk/harness-claude-code 1.0.74 github npm
@ai-sdk/harness-codex 1.0.73 github npm
@ai-sdk/harness-deepagents 1.0.71 github npm
@ai-sdk/harness-grok-build 1.0.7 github npm
@ai-sdk/harness-opencode 1.0.72 github npm
@ai-sdk/harness-pi 1.0.72 github npm
@ai-sdk/langchain 3.0.65 github npm
@ai-sdk/llamaindex 3.0.65 github npm
@ai-sdk/otel 1.0.65 github npm
@ai-sdk/policy-opa 1.0.65 github npm
@ai-sdk/react 4.0.68 github npm
@ai-sdk/rsc 3.0.65 github npm
@ai-sdk/sandbox-just-bash 1.0.71 github npm
@ai-sdk/sandbox-vercel 1.0.71 github npm
@ai-sdk/svelte 5.0.65 github npm
@ai-sdk/tui 1.0.66 github npm
@ai-sdk/vue 4.0.65 github npm
@ai-sdk/workflow 1.0.65 github npm
@ai-sdk/workflow-harness 1.0.71 github npm

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON Schema: 'definitions' are not supported with output mode 'array' (OpenAI).

2 participants