Description
server/routes/experimental.ts line 87 uses zodToJsonSchema() from zod-to-json-schema@3.24.5 to convert tool parameter schemas for the HTTP API. This library is incompatible with Zod v4 — it returns garbage output for object schemas.
Example: a Zod v4 object schema with two string properties produces {"type": "string", "$schema": "http://json-schema.org/draft-07/schema#"} instead of the correct object schema. All property definitions, descriptions, and required fields are lost.
The prompt path (session/prompt.ts line 440) correctly uses z.toJSONSchema() which works with Zod v4. The experimental API endpoint should use the same method.
Related: #4357 (original report about lost descriptions, now fixed in the prompt path by Zod v4)
Steps to reproduce
- Define a custom tool with described parameters
- Query the experimental tools endpoint (
GET /experimental/tools?provider=...&model=...)
- Observe the returned parameter schemas are incorrect
Environment
- OpenCode: latest dev (
8daeacc98)
- OS: macOS 15.4 (arm64)
- Zod: v4, zod-to-json-schema: 3.24.5
Description
server/routes/experimental.tsline 87 useszodToJsonSchema()fromzod-to-json-schema@3.24.5to convert tool parameter schemas for the HTTP API. This library is incompatible with Zod v4 — it returns garbage output for object schemas.Example: a Zod v4 object schema with two string properties produces
{"type": "string", "$schema": "http://json-schema.org/draft-07/schema#"}instead of the correct object schema. All property definitions, descriptions, and required fields are lost.The prompt path (
session/prompt.tsline 440) correctly usesz.toJSONSchema()which works with Zod v4. The experimental API endpoint should use the same method.Related: #4357 (original report about lost descriptions, now fixed in the prompt path by Zod v4)
Steps to reproduce
GET /experimental/tools?provider=...&model=...)Environment
8daeacc98)