tool (math.ts from the doc) fails: "Invalid input: expected string, received number" #2644

Closed
opened 2026-02-16 17:36:35 -05:00 by yindo · 3 comments
Owner

Originally created by @e-roux on GitHub (Nov 6, 2025).

Originally assigned to: @TommyHwang on GitHub.

Description

Tried the math.ts (https://opencode.ai/docs/custom-tools/) tool example. Get an error:

I'll multiply 10 and 43 using the math_multiply tool and return the result.
⚙ math_multiply [a=10, b=43]
Tool execution aborted


[
  {
    "code": "invalid_union",
    "errors": [
      [
        {
          "expected": "string",
          "code": "invalid_type",
          "path": [
            "state",
            "output"
          ],
          "message": "Invalid input: expected string, received number"
        }
      ],

Not sure of what's happening. Looks like a bug or is the user faulty?

OpenCode version

1.0.35

Steps to reproduce

1 . copy the math.ts into opencode/tool/math.sj
2. call the tool from opencode
3

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Originally created by @e-roux on GitHub (Nov 6, 2025). Originally assigned to: @TommyHwang on GitHub. ### Description Tried the math.ts (https://opencode.ai/docs/custom-tools/) tool example. Get an error: ```shell I'll multiply 10 and 43 using the math_multiply tool and return the result. ⚙ math_multiply [a=10, b=43] Tool execution aborted [ { "code": "invalid_union", "errors": [ [ { "expected": "string", "code": "invalid_type", "path": [ "state", "output" ], "message": "Invalid input: expected string, received number" } ], ``` Not sure of what's happening. Looks like a bug or is the user faulty? ### OpenCode version 1.0.35 ### Steps to reproduce 1 . copy the math.ts into opencode/tool/math.sj 2. call the tool from opencode 3 ### Screenshot and/or share link _No response_ ### Operating System _No response_ ### Terminal _No response_
yindo added the good first issuedocumentation labels 2026-02-16 17:36:35 -05:00
yindo closed this issue 2026-02-16 17:36:35 -05:00
Author
Owner

@TommyHwang commented on GitHub (Nov 6, 2025):

Hello. Thank you always for your awesome works. 👍

If you are okay, can I assign to this issue?

@TommyHwang commented on GitHub (Nov 6, 2025): Hello. Thank you always for your awesome works. 👍 If you are okay, can I assign to this issue?
Author
Owner

@rekram1-node commented on GitHub (Nov 6, 2025):

@TommyHwang sure thing

@rekram1-node commented on GitHub (Nov 6, 2025): @TommyHwang sure thing
Author
Owner

@e-roux commented on GitHub (Nov 7, 2025):

👍 Thanks!

@e-roux commented on GitHub (Nov 7, 2025): 👍 Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2644