Skip to content

Commit 486840c

Browse files
Joey Barkleyclaude
andcommitted
fix(opencode): replace zodToJsonSchema with z.toJSONSchema for Zod v4 compat
zodToJsonSchema from [email protected] produces incorrect output with Zod v4 schemas (returns {"type":"string"} for object schemas, losing all properties and descriptions). Switch the experimental tools API endpoint to z.toJSONSchema() which is Zod v4's built-in converter and correctly preserves .describe() metadata. Fixes anomalyco#20807 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 8daeacc commit 486840c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎packages/opencode/src/server/routes/experimental.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { Instance } from "../../project/instance"
88
import { Project } from "../../project/project"
99
import { MCP } from "../../mcp"
1010
import { Session } from "../../session"
11-
import { zodToJsonSchema } from "zod-to-json-schema"
1211
import { errors } from "../error"
1312
import { lazy } from "../../util/lazy"
1413
import { WorkspaceRoutes } from "./workspace"
@@ -83,8 +82,11 @@ export const ExperimentalRoutes = lazy(() =>
8382
tools.map((t) => ({
8483
id: t.id,
8584
description: t.description,
86-
// Handle both Zod schemas and plain JSON schemas
87-
parameters: (t.parameters as any)?._def ? zodToJsonSchema(t.parameters as any) : t.parameters,
85+
// Convert Zod schemas to JSON Schema via Zod v4 built-in.
86+
// The previous zodToJsonSchema ([email protected]) is incompatible with Zod v4.
87+
parameters: typeof (t.parameters as any)?.parse === "function"
88+
? z.toJSONSchema(t.parameters as any)
89+
: t.parameters,
8890
})),
8991
)
9092
},

0 commit comments

Comments
 (0)