anomalyco / anomalyco/opencode
tools: foreign Effect NonEmptyString schemas reject valid input
@jlongster is already working on this.
Since Sep 15, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
Tools registered by a local plugin with an Effect schema created outside OpenCode's bundled Effect runtime are advertised correctly but reject valid input at execution time.
For example, Schema.NonEmptyString generates the correct minLength: 1 JSON Schema, but valid values such as "alpha" and "beta" fail runtime decoding as if they were empty.
Environment
- opencode version: 2.0.3
- OS: Darwin 25.6.0 arm64
- Terminal: Ghostty (
TERM=xterm-ghostty,COLORTERM=truecolor) - Shell:
/bin/zsh - Install/channel: latest
- Active plugins: local plugin
.opencode/plugins/non-empty-array/index.ts
Reproduction
-
Create a local plugin that registers a direct tool with an Effect schema:
import { Plugin } from "@opencode/plugin/effect"; import { Effect, Schema } from "effect"; const Input = Schema.Struct({ values: Schema.Array(Schema.NonEmptyString), }); export default Plugin.define({ id: "repro.non-empty-array", effect: (context) => context.tool.transform((editor) => { editor.add({ name: "accept_non_empty_strings", description: "Accept an array of non-empty strings and return them unchanged.", input: Input, options: { codemode: false }, execute: (input) => Effect.succeed({ content: `EXECUTED:${JSON.stringify(input.values)}`, }), }); }), }); -
Start OpenCode with the plugin enabled.
-
Ask OpenCode to call
accept_non_empty_stringswith:{"values":["alpha","beta"]}
Expected Behavior
The tool should execute and return:
EXECUTED:["alpha","beta"]
Actual Behavior
The tool is advertised correctly, but execution fails with:
Invalid arguments for tool "accept_non_empty_strings":
- values[0]: Expected a value with a length of at least 1
- values[1]: Expected a value with a length of at least 1
Additional Context
The issue is reproducible consistently with OpenCode 2.0.3, @opencode/plugin 2.0.3, and Effect 4.0.0-rc.112.
The same values decode successfully when tested directly with the plugin's Effect runtime:
Schema.decodeUnknownSync(Schema.NonEmptyString)("alpha");
A tool using Schema.String instead of Schema.NonEmptyString succeeds. A tool using an equivalent plain JSON Schema also succeeds.
The generated model-facing JSON Schema is correct (minLength: 1). The failure occurs during runtime input decoding, suggesting that OpenCode is applying its bundled Effect decoder directly to an Effect schema created by the external plugin runtime.
A workaround is to use JSON Schema for plugin tool inputs. The likely framework fix is to normalize foreign Effect schemas before decoding them, or ensure plugin schemas are decoded using the originating Effect runtime.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.