fix: custom realtime models broken under zod 4.4+#126
Merged
AdirAmsalem merged 1 commit intomainfrom Apr 30, 2026
Merged
Conversation
Zod 4.4 stopped treating `z.any()` as implicitly optional inside `z.object`, so omitting `inputSchema` on a `CustomModelDefinition` started failing realtime connect validation. Mark `inputSchema` as explicitly optional to match the TypeScript type and keep custom models working across zod 4.0–4.4+.
commit: |
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.
Summary
A fresh install of
@decartai/sdkstarted failing realtime connect for users who pass a custom model definition without aninputSchema. The error surfaces as:This regression is triggered by zod 4.4, which stopped treating
z.any()as implicitly optional inside object schemas. Built-in models (models.realtime("lucy-2.1"), etc.) were unaffected because they always setinputSchema. Users following our ownexamples/sdk-core/realtime/custom-model.tspattern were broken.The fix aligns the runtime schema with the existing TypeScript type (
CustomModelDefinition.inputSchema?) and works under zod 4.0–4.4+.Usage (unchanged, now actually works on zod 4.4+)
Test plan
inputSchemaunder zod@4.4.1fps, etc.)pnpm --filter @decartai/sdk typecheckpnpm --filter @decartai/sdk test(175/175 pass)Note
Low Risk
Low risk, single-field validation change that relaxes runtime model definition parsing to match existing TS types; main impact is allowing previously-rejected custom realtime model configs under newer Zod versions.
Overview
Fixes a regression in
@decartai/sdkmodel validation by makingmodelDefinitionSchema.inputSchemaoptional, aligning runtime Zod validation withCustomModelDefinition.inputSchema?.This restores compatibility for custom model definitions (notably realtime
connect) that omitinputSchema, which started failing validation under Zod 4.4+.Reviewed by Cursor Bugbot for commit 27d52eb. Bugbot is set up for automated code reviews on this repo. Configure here.