Skip to content

Custom Tools Failing with TypeError #13365

Closed

Description

@CyberSecDef

Description

This is happening on both Windows and RHEL installs. any call to a custom tool (global or project specific) results in a TypeError: text2.split is not a function error message. This is based off clean installs that are fully updated. There are no custom plugins used. This is also occuring with local LLMs and commerical ones like Google Gemini. This is impacting all tools, even ones copy/pasted from the documentation (math - add).

Plugins

NA

OpenCode version

1.1.63

Steps to reproduce

  1. launch opencode
  2. Connect to LLM service
  3. prompt with something like "use the math-add tool to add the numbers 5 and 7"
  4. Recieve response:
    ⚙ math_add [a=5, b=7]
    TypeError: text2.split is not a function. (In 'text2.split( )', 'text2.split' is undefined)

the custom tool does not have text2 variable or split method calls in the code. no other 'source' data is outputted, so this is really hard to trace down

Screenshot and/or share link

No response

Operating System

RHEL 8, Windows 11

Terminal

Putty and Windows Terminal

Activity

  1. github-actions commented on Feb 12, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of or related to existing tool-execution TypeErrors. Please check:

    The text2.split is not a function error pattern is similar to other reported .split is not a function crashes in tool handling code (#4484, #4869).

    If this is indeed a duplicate, the maintainers may consolidate these reports.

  2. CyberSecDef commented on Feb 12, 2026

    @CyberSecDef
    Author

    This shouldn't be #12336 as this happens for both global and project level tools
    This shouldnt be #12987 as this isn't an MCP tool, rather a custom tool (.opencode/tools/math.ts)
    This should be #13042 as this is a custom tool
    This shouldnt be #13062 as this is a custom tool
    This isnt #4484 as there are no sub commands given on the command line
    This isn't #4869 as it is happening with one of the latest releases.

  3. CyberSecDef commented on Feb 12, 2026

    @CyberSecDef
    Author

    it appears that if the tool returns just a string, it works. might be worth updating the custom tool documentation to state that. returning numbers or objects is a trigger for this issue.

  4. added a commit that references this issue on Feb 13, 2026
    38fca17
  5. github-actions commented on Apr 14, 2026

    @github-actions
    Contributor

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

  6. pablomadriaga commented on Apr 14, 2026

    @pablomadriaga

    I've found a workaround for this bug. The issue is that OpenCode's custom tools don't handle object returns properly - it tries to call .split() on non-string values.
    Workaround: Change your custom tool to return ONLY a string instead of an object.
    Example fix in yaml_edit.ts:
    // BEFORE (causes text2.split error):
    return {
    results,
    summary: ${successCount} succeeded, ${errorCount} errors
    }
    // AFTER (works):
    const outputLines = results.map(r =>
    ${r.file}: ${r.status} - ${r.message}
    )
    return outputLines.join('\n') + '\nSummary: ${successCount} succeeded...`
    This fixed the text2.split is not a function error in my custom yaml_edit tool.

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions