[PR #13408] fix(opencode): coerce custom tool output to string before processing #14651

Open
opened 2026-02-16 18:19:25 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13408

State: open
Merged: No


What does this PR do?

Fixes #13365

Custom tools that return non-string values (numbers, objects) crash with TypeError: text2.split is not a function. The fromPlugin wrapper in registry.ts passes the raw result from def.execute() directly to Truncate.output(), which calls .split("\n") on it — that blows up when the value isn't a string.

Now the result gets coerced to a string (JSON.stringify for non-strings) before hitting truncation or being stored as output.

How did you verify your code works?

Traced the call chain from fromPluginTruncate.output.split("\n") and confirmed the crash path. Added a test for Truncate.output with string inputs. bun typecheck and bun turbo test both pass (only pre-existing Bedrock timeout failures).

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13408 **State:** open **Merged:** No --- ### What does this PR do? Fixes #13365 Custom tools that return non-string values (numbers, objects) crash with `TypeError: text2.split is not a function`. The `fromPlugin` wrapper in `registry.ts` passes the raw result from `def.execute()` directly to `Truncate.output()`, which calls `.split("\n")` on it — that blows up when the value isn't a string. Now the result gets coerced to a string (`JSON.stringify` for non-strings) before hitting truncation or being stored as output. ### How did you verify your code works? Traced the call chain from `fromPlugin` → `Truncate.output` → `.split("\n")` and confirmed the crash path. Added a test for `Truncate.output` with string inputs. `bun typecheck` and `bun turbo test` both pass (only pre-existing Bedrock timeout failures).
yindo added the pull-request label 2026-02-16 18:19:25 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14651