fix(zod): infer parsed tool callback arguments#1992
Open
HAYDEN-OAI wants to merge 1 commit into
Open
Conversation
OkTest Summary❌ Failed for Node SDK PR #1992. SDK merge ( |
jbeckwith-oai
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the type flow for both Zod tool helpers and the new regression coverage. InferZodType<Parameters> matches the value returned by parseZodObject() and now propagates the parsed output type consistently through $callback, $parseRaw, and __arguments for both Chat Completions and Responses. The compareType assertions are exact, so they would fail if these properties regressed back to the schema object type.
I also validated the PR commit locally with the focused Zod suite (26 tests), pnpm build, and the full pnpm lint pipeline; all passed. No blocking issues found.
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
Fixes #1244.
zodFunction()andzodResponsesFunction()already infer the parsed Zod output for the callback supplied in their options, but their returned auto-parseable tool types recorded the raw Zod schema type asarguments. BecauseAutoParseableToolandAutoParseableResponseTooluse that field for their helper properties, callers saw$callback,$parseRaw, and__argumentstyped as the schema object instead of the parsed tool arguments.This updates both Zod helper return types to use
InferZodType<Parameters>forarguments. The change is type-only and does not alter parsing or callback behavior at runtime.The type regression checks now verify the inferred parsed argument type for
$callback,$parseRaw, and__argumentson both chat completion and Responses API tools.Additional context & links
pnpm test --runInBand tests/helpers/zod.test.tspnpm lintpnpm test --runInBand