Skip to content

fix(zod): support only provably JSON-native structured outputs - #2396

Open
HAYDEN-OAI wants to merge 5 commits into
mainfrom
agent/zod-v3-json-native-supported-subset-vnjsgdbk
Open

fix(zod): support only provably JSON-native structured outputs#2396
HAYDEN-OAI wants to merge 5 commits into
mainfrom
agent/zod-v3-json-native-supported-subset-vnjsgdbk

Conversation

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor

Supersedes #2376 with an intentionally smaller, fail-closed contract. The previous PR accumulated 8,554 added lines while trying to infer the behavior of arbitrary Zod transformations; this replacement does not modify the vendored converter.

  • Document and enforce the Zod v3 JSON-native subset at the shared strict-helper boundary.
  • Reject native Date/BigInt/Map/Set/Promise values, effects/refinements, pipelines, intersections, invalid defaults, and ambiguous unions with actionable errors.
  • Preserve disjoint/discriminated unions, recursive/shared schemas, non-strict Realtime behavior, and the existing Zod v4 converter.
  • Represent precision-sensitive integers as validated decimal strings and convert with BigInt only after parsing.
  • Reconcile the few existing fixtures that explicitly depended on unsupported behavior.

Verification: 65 regression-first failures became 83 passing boundary tests; 456 focused Zod/parser tests, 3,372 handwritten tests, 559 generated tests, full formatting/lint, repository types, CommonJS/ESM production build, published TypeScript 4.9/current consumers, and the packed npm artifact all pass.

Additional schema capabilities should be considered as separate, narrowly scoped follow-ups rather than expanding this boundary into a general transformation interpreter.

@openai-sdks

openai-sdks Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

OkTest Summary

237/237 SDK tests passed in 11.405s for Node SDK PR #2396.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 208ms
tests/chat-completions-create.test.ts ✅ Passed 298ms
tests/chat-completions-stream.test.ts ✅ Passed 254ms
tests/files-content-binary.test.ts ✅ Passed 216ms
tests/files-create-multipart.test.ts ✅ Passed 210ms
tests/files-list-pagination.test.ts ✅ Passed 199ms
tests/initialize-config.test.ts ✅ Passed 204ms
tests/instance-isolation.test.ts ✅ Passed 145ms
tests/models-list.test.ts ✅ Passed 178ms
tests/responses-background-lifecycle.test.ts ✅ Passed 216ms
tests/responses-body-method-errors.test.ts ✅ Passed 411ms
tests/responses-cancel-timeout.test.ts ✅ Passed 239ms
tests/responses-cancel.test.ts ✅ Passed 276ms
tests/responses-compact-retries.test.ts ✅ Passed 275ms
tests/responses-compact.test.ts ✅ Passed 322ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 175ms
tests/responses-create-advanced.test.ts ✅ Passed 209ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.097s
tests/responses-create-errors.test.ts ✅ Passed 263ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 199ms
tests/responses-create-retries.test.ts ✅ Passed 299ms
tests/responses-create-stream-failures.test.ts ✅ Passed 232ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 2.156s
tests/responses-create-stream-wire.test.ts ✅ Passed 2.429s
tests/responses-create-stream.test.ts ✅ Passed 135ms
tests/responses-create-terminal-states.test.ts ✅ Passed 367ms
tests/responses-create-timeout.test.ts ✅ Passed 282ms
tests/responses-create.test.ts ✅ Passed 305ms
tests/responses-delete.test.ts ✅ Passed 227ms
tests/responses-input-items-errors.test.ts ✅ Passed 348ms
tests/responses-input-items-list.test.ts ✅ Passed 165ms
tests/responses-input-items-options.test.ts ✅ Passed 196ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 248ms
tests/responses-input-tokens-count.test.ts ✅ Passed 291ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.065s
tests/responses-not-found-errors.test.ts ✅ Passed 342ms
tests/responses-parse.test.ts ✅ Passed 179ms
tests/responses-retrieve-retries.test.ts ✅ Passed 310ms
tests/responses-retrieve.test.ts ✅ Passed 237ms
tests/responses-stored-method-errors.test.ts ✅ Passed 797ms
tests/retry-behavior.test.ts ✅ Passed 3.112s
tests/sdk-error-shape.test.ts ✅ Passed 365ms

View OkTest run #32174812497

SDK merge (da4113677c54) · head (6037a8a6f7bc) · base (dd945e63d9c3) · OkTest (7e7850017529)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71780bf0c5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/helpers/zod-v3-strict-schema.ts
Comment thread src/helpers/zod-v3-strict-schema.ts Outdated
Comment thread src/helpers/zod-v3-strict-schema.ts Outdated
Comment thread src/helpers/zod-v3-strict-schema.ts Outdated
Comment thread src/helpers/zod-v3-strict-schema.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6cbcdbb468

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/helpers/zod-v3-strict-schema.ts
Comment thread src/helpers/zod-v3-strict-schema.ts
Comment thread src/helpers/zod-v3-strict-schema.ts Outdated
Comment thread src/helpers/zod-v3-strict-schema.ts
Comment thread src/helpers/zod-v3-strict-schema.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7c292d83a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/helpers/zod-v3-strict-schema.ts
Comment thread src/helpers/zod-v3-strict-schema.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d5f565293f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/helpers/zod-v3-strict-schema.ts
Comment thread src/helpers/zod-v3-strict-schema.ts
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.

1 participant