You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Custom tool with tool.schema.number() argument crashes with "Cannot read properties of undefined (reading 'split')" #38956
Custom tools defined via @opencode-ai/plugin crash with Cannot read properties of undefined (reading 'split') when the tool's args schema includes a tool.schema.number() field and the LLM calls the tool with an argument for that field. Tools with no arguments work fine. Tools using only tool.schema.string() arguments also work fine — the crash is specific to the number type.
@opencode-ai/plugin version: 1.18.5 (also reproduced on 1.18.4)
Reproduced with two different models/providers: deepseek-v4-flash-free and Gemini 3.5 — not model-specific.
Tool loaded from a project-local .opencode/tools/game.ts
Expected behavior
Tool executes and returns 9.
Actual behavior
Cannot read properties of undefined (reading 'split')
The agent then silently falls back to computing the sum itself in text, without surfacing the error clearly to the user (only a one-line inline error appears before the tool result).
Workaround found
Changing both args to tool.schema.string() and converting inside execute avoids the crash entirely:
exportconstadd=tool({description: "Add two numbers",args: {a: tool.schema.string().describe("First number"),b: tool.schema.string().describe("Second number"),},asyncexecute(args){returnString(Number(args.a)+Number(args.b))},})
This strongly suggests the bug is in the Zod→JSON-Schema conversion path specific to the number type when serializing the tool schema for the model/provider, not in the model's tool-calling behavior itself (reproduced across two unrelated providers).
Additional notes
No matching stack trace appears in ~/.local/share/opencode/log/*.log — the error appears to be caught/displayed only in the session UI, not logged at ERROR level, which made this harder to trace. Might be worth logging the full stack trace for tool execution errors.
Happy to provide more detail or test a patch if useful.
Activity
github-actions commentedon Sep 25, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.