Skip to content

feat(compat): registerTool/registerPrompt accept raw Zod shape, auto-wrap with z.object() - #1901

Merged
felixweinberger merged 16 commits into
mainfrom
fweinberger/v2-bc-register-rawshape
Apr 29, 2026
Merged

felixweinberger merged 16 commits into
mainfrom
fweinberger/v2-bc-register-rawshape

Merge branch 'main' into fweinberger/v2-bc-register-rawshape

617830b
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Apr 29, 2026 in 45m 49s

Code review found 2 potential issues

Found 2 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 0
🟡 Nit 2
🟣 Pre-existing 0
Severity File:Line Issue
🟡 Nit packages/core/src/util/zodCompat.ts:12-18 isZodV4Schema admits zod/mini fields, which crash on tools/list after auto-wrap
🟡 Nit packages/core/src/util/zodCompat.ts:1-5 Stale 'library-agnostic' rationale in zodCompat.ts file header after merge 9b7ee90

Annotations

Check warning on line 18 in packages/core/src/util/zodCompat.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

isZodV4Schema admits zod/mini fields, which crash on tools/list after auto-wrap

nit: same guard-over-acceptance class as the ArkType (0152b266) and Zod-v3 (068ff56c) cases — `isZodV4Schema` keys on `'_zod' in v`, which is also present on **`zod/mini`** schemas. `{ a: zm.string() }` passes `isZodRawShape`, gets wrapped as classic `z.object({...})`, and on `tools/list` → `std.jsonSchema.input(...)` throws `[toJSONSchema]: Non-representable type encountered: string` (the wrapper has `~standard.jsonSchema`, so #1895's working `z.toJSONSchema` fallback is bypassed — meaning auto

Check warning on line 5 in packages/core/src/util/zodCompat.ts

See this annotation in the file changed.

@claude claude / Claude Code Review

Stale 'library-agnostic' rationale in zodCompat.ts file header after merge 9b7ee90

nit: this file header says it's "Kept separate from `standardSchema.ts` so that file stays library-agnostic", and the reply on the earlier thread said "`standardSchema.ts` no longer imports zod" — both were true at 0febd83f, but merge 9b7ee90 brought in #1895 (b256546), which re-added `import * as z from 'zod/v4'` to `standardSchema.ts:9` for the `z.toJSONSchema()` fallback at line 178. Suggest softening to e.g. "Kept separate so `standardSchema.ts` stays focused on the Standard Schema spec inte