feat(helpers): add zod realtime function helper#1996
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15c277ef73
ℹ️ 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".
…-zod-realtime-function
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0ecd61bf5d
ℹ️ 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".
jbeckwith-oai
left a comment
There was a problem hiding this comment.
Reviewed the Realtime Zod helper across Zod v3, v4, and v4 mini, including optional/defaulted fields, pipeline input schemas, generated Realtime wire shape, public types/package exports, and the two previously reported findings. The current head addresses those findings cleanly and I found no remaining substantive issues.\n\nVerified locally:\n- focused Zod helper suite (32 passed)\n- full runnable test corpus (1,201 passed, 1 skipped; dedicated Steady port, with the harness-specific test rerun without the base-URL override)\n- pnpm lint (including build, type checks, publint, and JSR dry run)\n- Realtime session.update compile/wire smoke test for Zod v3 and v4\n- git diff --check
Summary
zodRealtimeFunction()toopenai/helpers/zodstrict, which is not part of the RealtimeRealtimeFunctionToolshapeMotivation
Fixes #1809.
zodResponsesFunction()is close to what Realtime callers need, but it always emitsstrict: true. Realtime function tools use the flat{ type, name, description?, parameters }shape and do not support that field, so raw Realtime users currently have to convert Zod schemas by hand.Behavior
The new helper returns a regular Realtime function tool definition with
type,name, optionaldescription, and JSON Schemaparameters. It reuses the existing Zod conversion path so behavior stays consistent across the helper family, including current Zod v3, v4, and v4 mini support.The helper is intentionally definition-only. It does not attach callback or parser metadata because the raw Realtime client does not have a
runTools()-style consumer; callers still parse function-call arguments with their original Zod schema.Validation
pnpm exec jest tests/helpers/zod.test.ts --runInBandpnpm exec prettier --check src/helpers/zod.ts tests/helpers/zod.test.tsgit diff --checkpnpm run lint