Repository navigation
fix(zod): prevent generated definition name collisions - #2346
Merged
HAYDEN-OAI merged 1 commit intoAug 15, 2026
Merged
HAYDEN-OAI merged 1 commit into
HAYDEN-OAI merged 1 commit into
Conversation
Contributor
jbeckwith-oai
approved these changes
Aug 14, 2026
jbeckwith-oai
left a comment
Contributor
There was a problem hiding this comment.
Reviewed exact head 2f157b2. The Zod v3 definition-name allocator now distinguishes real roots from flattened nested collisions, reuses true aliases by underlying definition identity, and skips occupied caller/generated/root names deterministically with own-property-safe lookup. Caller definition maps are cloned only for the mutating extraction strategy, preserving frozen inputs and the behavior of other strategies; Zod v4 remains isolated. Focused public-helper coverage is comprehensive, strict thermo is clean, and all applicable exact-head CI is green.
HAYDEN-OAI
deleted the
agent/hayden-oai-zod-v3-definition-collisions-20260814-ykferedw
branch
August 15, 2026 02:18
Merged
This branch was previously 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.
Changes being requested
Fix silent Zod v3 structured-output/tool schema corruption when distinct schema paths flatten to the same generated definition name. For example, repeated
a.bstring anda_properties_bnumber schemas previously both referenced the same overwritten definition, so the model-visible schema required a number while the local Zod parser required a string. This affectedzodResponseFormat,zodTextFormat,zodFunction,zodResponsesFunction, andzodRealtimeFunction._1,_2, ... suffixes for distinct generated or caller-provided definitions.extract-to-root+duplicate-refstrategy that can mutate them, supporting frozen maps while preserving identity-dependent behavior in all other converter modes.Only handwritten vendored converter files and a new handwritten test file are changed; none has a Castiron generated header or appears in the generated/legacy file inventory.
Additional context & links
Regression-first baseline on untouched
main: the initial eight targeted tests failed, reproducing all five public-helper collisions, supplied-definition overwrite/mutation, frozen-map failure, and the reserved-root collision.Verification
pnpm test:unit tests/helpers/zod-definition-collisions.test.ts tests/helpers/zod.test.ts— 66 passed, including 24 focused collision regressions.pnpm test:unit— 2,114 passed across 71 handwritten test files.pnpm lint— passed across 609 files.pnpm exec tsc— passed.pnpm exec oxfmt --check src/_vendor/zod-to-json-schema/parseDef.ts src/_vendor/zod-to-json-schema/Options.ts tests/helpers/zod-definition-collisions.test.ts— passed.pnpm build— passed, including CJS/ESM package import smoke checks../node_modules/typescript-4-9/bin/tsc --project dist/src/tsconfig.json --noEmit— passed../node_modules/typescript/bin/tsc --project dist/src/tsconfig.json --noEmit— passed.pnpm exec publint dist— passed with the existing non-fatal vendored CommonJS default-export advisory.