Skip to content

Fix optional Zod fields in native structured output - #336

Draft
EricLiu2795 wants to merge 1 commit into
mainfrom
fix/structured-output-optional-zod
Draft

Fix optional Zod fields in native structured output#336
EricLiu2795 wants to merge 1 commit into
mainfrom
fix/structured-output-optional-zod

Conversation

@EricLiu2795

Copy link
Copy Markdown
Collaborator

Summary

Fixes #335.

The shared structured-output path could fail before making a provider request when native json-schema mode was selected for a Zod schema containing optional object properties such as:

z.object({
  required: z.string(),
  optional: z.string().optional(),
})

The adapter now detects this native-schema incompatibility before invocation and uses the existing strict-JSON prompt plus local Zod validation fallback. Required schemas continue to use native JSON Schema, and ordinary provider failures are not rerouted.

The current Founder Weekly Review recommendation schema is covered without changing the FWR schema itself.

Validation

  • Shared LLM surface: 6 suites, 111 tests passed
  • Focused structured-output regression: 8 tests passed
  • Current-main FWR generation tests: 30 tests passed
  • Affected-package typechecks: PASS
  • Changed-file lint: PASS
  • Formatting: PASS
  • git diff --check: PASS
  • No live provider calls were made; local mock endpoints proved the path proceeds beyond schema preparation.

No migrations, provider-specific routing, retry/outbox logic, or unrelated infrastructure were changed.

@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
launch-stack Error Error Aug 16, 2026 3:51pm
pdr-ai-v2 Error Error Aug 16, 2026 3:51pm

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Structured output fails on optional Zod fields in native JSON-schema mode

1 participant