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
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
launch opencode
Connect to LLM service
prompt with something like "use the math-add tool to add the numbers 5 and 7"
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
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.
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.
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.
Activity
github-actions commentedon Feb 12, 2026
This issue might be a duplicate of or related to existing tool-execution TypeErrors. Please check:
The
text2.split is not a functionerror pattern is similar to other reported.split is not a functioncrashes in tool handling code (#4484, #4869).If this is indeed a duplicate, the maintainers may consolidate these reports.
CyberSecDef commentedon Feb 12, 2026
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.
CyberSecDef commentedon Feb 12, 2026
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.
fix(opencode): coerce custom tool output to string before processing
github-actions commentedon Apr 14, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.
pablomadriaga commentedon Apr 14, 2026
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.