Skip to content

fix(zod): infer parsed tool callback arguments#1992

Open
HAYDEN-OAI wants to merge 1 commit into
mainfrom
dev/hayden/issue-1244-zod-tool-callback-types
Open

fix(zod): infer parsed tool callback arguments#1992
HAYDEN-OAI wants to merge 1 commit into
mainfrom
dev/hayden/issue-1244-zod-tool-callback-types

Conversation

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor
  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Fixes #1244.

zodFunction() and zodResponsesFunction() 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 as arguments. Because AutoParseableTool and AutoParseableResponseTool use that field for their helper properties, callers saw $callback, $parseRaw, and __arguments typed as the schema object instead of the parsed tool arguments.

This updates both Zod helper return types to use InferZodType<Parameters> for arguments. 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 __arguments on both chat completion and Responses API tools.

Additional context & links

@HAYDEN-OAI HAYDEN-OAI marked this pull request as ready for review July 13, 2026 20:19
@HAYDEN-OAI HAYDEN-OAI requested a review from a team as a code owner July 13, 2026 20:19
@openai-sdks

openai-sdks Bot commented Jul 13, 2026

Copy link
Copy Markdown

OkTest Summary

Failed for Node SDK PR #1992.

View OkTest run #29281934782

SDK merge (914803504393) · head (1fa733a58134) · base (ec2f57fd0d66) · OkTest (cb7f0514ccd2)

@jbeckwith-oai jbeckwith-oai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

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.

Incorrect type for callback function

2 participants