Skip to content

feat(helpers): add zod realtime function helper#1996

Merged
HAYDEN-OAI merged 4 commits into
mainfrom
dev/hayden/issue-1809-zod-realtime-function
Jul 22, 2026
Merged

feat(helpers): add zod realtime function helper#1996
HAYDEN-OAI merged 4 commits into
mainfrom
dev/hayden/issue-1809-zod-realtime-function

Conversation

@HAYDEN-OAI

Copy link
Copy Markdown
Contributor

Summary

  • add zodRealtimeFunction() to openai/helpers/zod
  • generate Realtime function tool definitions from Zod v3, Zod v4, and Zod v4 mini schemas
  • omit strict, which is not part of the Realtime RealtimeFunctionTool shape
  • add focused coverage for the generated schema and wire format

Motivation

Fixes #1809.

zodResponsesFunction() is close to what Realtime callers need, but it always emits strict: 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, optional description, and JSON Schema parameters. 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 --runInBand
  • pnpm exec prettier --check src/helpers/zod.ts tests/helpers/zod.test.ts
  • git diff --check
  • pnpm run lint

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

openai-sdks Bot commented Jul 13, 2026

Copy link
Copy Markdown

OkTest Summary

237/237 SDK tests passed in 10.394s for Node SDK PR #1996.

Test results — 42 files
Test Result Time
tests/chat-completions-complex-body.test.ts ✅ Passed 158ms
tests/chat-completions-create.test.ts ✅ Passed 260ms
tests/chat-completions-stream.test.ts ✅ Passed 137ms
tests/files-content-binary.test.ts ✅ Passed 171ms
tests/files-create-multipart.test.ts ✅ Passed 141ms
tests/files-list-pagination.test.ts ✅ Passed 144ms
tests/initialize-config.test.ts ✅ Passed 179ms
tests/instance-isolation.test.ts ✅ Passed 101ms
tests/models-list.test.ts ✅ Passed 144ms
tests/responses-background-lifecycle.test.ts ✅ Passed 219ms
tests/responses-body-method-errors.test.ts ✅ Passed 326ms
tests/responses-cancel-timeout.test.ts ✅ Passed 205ms
tests/responses-cancel.test.ts ✅ Passed 232ms
tests/responses-compact-retries.test.ts ✅ Passed 238ms
tests/responses-compact.test.ts ✅ Passed 241ms
tests/responses-create-advanced-stream.test.ts ✅ Passed 119ms
tests/responses-create-advanced.test.ts ✅ Passed 214ms
tests/responses-create-disconnect.test.ts ✅ Passed 1.16s
tests/responses-create-errors.test.ts ✅ Passed 197ms
tests/responses-create-malformed-api-responses.test.ts ✅ Passed 126ms
tests/responses-create-retries.test.ts ✅ Passed 262ms
tests/responses-create-stream-failures.test.ts ✅ Passed 227ms
tests/responses-create-stream-timeout.test.ts ✅ Passed 2.16s
tests/responses-create-stream-wire.test.ts ✅ Passed 2.618s
tests/responses-create-stream.test.ts ✅ Passed 74ms
tests/responses-create-terminal-states.test.ts ✅ Passed 201ms
tests/responses-create-timeout.test.ts ✅ Passed 188ms
tests/responses-create.test.ts ✅ Passed 149ms
tests/responses-delete.test.ts ✅ Passed 186ms
tests/responses-input-items-errors.test.ts ✅ Passed 179ms
tests/responses-input-items-list.test.ts ✅ Passed 184ms
tests/responses-input-items-options.test.ts ✅ Passed 102ms
tests/responses-input-tokens-count-timeout.test.ts ✅ Passed 254ms
tests/responses-input-tokens-count.test.ts ✅ Passed 239ms
tests/responses-malformed-inputs.test.ts ✅ Passed 2.289s
tests/responses-not-found-errors.test.ts ✅ Passed 230ms
tests/responses-parse.test.ts ✅ Passed 169ms
tests/responses-retrieve-retries.test.ts ✅ Passed 262ms
tests/responses-retrieve.test.ts ✅ Passed 219ms
tests/responses-stored-method-errors.test.ts ✅ Passed 545ms
tests/retry-behavior.test.ts ✅ Passed 3.134s
tests/sdk-error-shape.test.ts ✅ Passed 260ms

View OkTest run #29774954394

SDK merge (0867a77940fe) · head (adeab6e02b68) · base (39a15b412fc1) · OkTest (38f2e7c0559b)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/helpers/zod.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/helpers/zod.ts

@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 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

@HAYDEN-OAI
HAYDEN-OAI merged commit ee59911 into main Jul 22, 2026
19 checks passed
@stainless-app stainless-app Bot mentioned this pull request Jul 22, 2026
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.

zod helpder for RealtimeFunctionTool

2 participants