Skip to content

experimental.ts uses zodToJsonSchema which is broken with Zod v4 #20807

Closed as not planned

Description

@jbmml

Description

server/routes/experimental.ts line 87 uses zodToJsonSchema() from [email protected] 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

  1. Define a custom tool with described parameters
  2. Query the experimental tools endpoint (GET /experimental/tools?provider=...&model=...)
  3. 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

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 3, 2026
  2. added a commit that references this issue on Apr 3, 2026
    486840c
  3. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  4. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions