anomalyco / anomalyco/opencode

Plugin tool args skip Zod parsing: defaults dropped, constraints unenforced

Open
#49,279 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Sep 16, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

Args from the model reach a plugin tool's execute() without being parsed by the declared Zod schema. The generated JSON Schema is correct, the model is shown default and minimum, but nothing validates or fills the args on the way in. .default() never applies and .min() never rejects.

Reported before in #20019 (same root cause as #9020, fixed for MCP tools in #11203). The stale bot auto-closed it with "if the issue is still relevant please open a new one". Still reproduces on v1.18.31. A comment there points at fromPlugin() in packages/opencode/src/tool/registry.ts bypassing Tool.define().

Plugins

local plugin registering a tool via @opencode-ai/plugin 1.18.30

OpenCode version

1.18.31

Steps to reproduce
  1. ~/.config/opencode/plugin/argprobe.ts:
import { tool, type Plugin } from "@opencode-ai/plugin"
const z = tool.schema
export const argprobe: Plugin = async () => ({
  tool: {
    argprobe: tool({
      description: "Echoes back what the runtime passed to execute.",
      args: {
        required: z.string(),
        withdefault: z.number().default(42),
        ranged: z.number().min(10).default(99),
      },
      async execute(args) {
        return "RECEIVED " + JSON.stringify(args)
      },
    }),
  },
})
  1. Ask the model to call argprobe with only required="a", then again with required="b" and ranged=1.

  2. Actual:

RECEIVED {"required":"a"}
RECEIVED {"required":"b","ranged":1}

Expected: the first call gets withdefault: 42, ranged: 99; the second is rejected because ranged is below its minimum of 10.

The schema served at /experimental/tool does carry both:

"withdefault": { "default": 42, "type": "number" },
"ranged": { "default": 99, "type": "number", "minimum": 10 }
Operating System

Ubuntu, Linux 6.17.0-1020-oracle

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.