Repository navigation
Description
Description
Version: 1.18.34 (binary at ~/.opencode/bin/opencode)
Describe the bug
When an assistant message contains multiple tool calls in parallel (especially mixing an MCP tool call with a built-in tool like bash), the arguments JSON delivered to the tool is sometimes corrupted in two distinct ways:
- Merged arguments — the arguments of one tool call are nested inside a parameter of another tool call.
- Truncated arguments — the JSON string is cut mid-value, failing with
Unexpected EOF.
The error surfaced to the model is:
Invalid input for tool <name>: JSON parsing failed: Text: <corrupted text>.
Error message: JSON Parse error: ...
Evidence from a real session (reproduced 5+ times)
Case 1 — merged: a parallel list_tasks (MCP) + bash call delivered this text to list_tasks (its fields param received the bash args object):
{"fields": {"command": "grep -rn \"attachment\\|anexo\" apps/api/src/routes/attachments.ts | head -5; echo \"---\"; ls apps/api/src/routes/ | grep -i attach", "workdir": "/home/jairo/Projetos/azyboard"}}
Error: JSON Parse error: Expected '}'
Case 2 — truncated: a parallel list_tasks (MCP) + other tool call delivered:
{"includeDescriptions":
Error: JSON Parse error: Unexpected EOF
Observed pattern
- Serial (non-parallel) tool calls never failed in the session.
- Parallel calls with two MCP tools also worked.
- Failures concentrated on MCP tool call + built-in tool call in the same assistant message.
- The corrupted text always starts with the first tool's parameter key, then splices in the second tool's arguments object.
Expected behavior
Each tool call in a parallel set receives its own, intact arguments JSON.
Impact
MCP tools with medium-sized argument payloads fail intermittently; the model must retry serially. Users of MCP servers see "tool errors" caused purely by the harness layer. As a mitigation on our side we reduced tool schema required-fields (less JSON per call), but the merging/truncation itself is in the harness.
Additional context
- The error strings
JSON parsing failed: Text: ${h}andInvalid input for tool '${YZ}': ${String(OW)}are present in the compiled binary. - Reproduced while using a local stdio MCP server (
bun run apps/mcp/src/index.ts) with@modelcontextprotocol/sdk.
Plugins
none
OpenCode version
1.18.34
Steps to reproduce
- Configure a local stdio MCP server in
opencode.json(e.g.{"mcp": {"my-server": {"type": "local", "command": ["bun", "run", "server.ts"]}}}) exposing tools with medium-sized JSON schemas (the Azy Boardlist_taskstool has ~14 optional params). - Start a session and, in a single assistant message, issue one MCP tool call in parallel with one built-in tool call (e.g.
bash), with non-trivial arguments on both. Example pair that failed repeatedly:my-server.list_taskswith{"fields": ["id","title","status","columnId"], "includeDescriptions": true}bashwith{"command": "grep -rn \"foo\\|bar\" apps/", "workdir": "/repo"}
- Repeat step 2 several times (intermittent, ~30–50% of parallel batches in my session; never happened with serial calls).
- Observe the tool error
Invalid input for tool <name>: JSON parsing failed: Text: ...where theText:shows either:- the bash args object nested under the MCP tool's first parameter key (merged calls), e.g.
{"fields": {"command": "grep ...", "workdir": "..."}}→JSON Parse error: Expected '}' - or the MCP tool's JSON cut mid-value (truncated call), e.g.
{"includeDescriptions":→JSON Parse error: Unexpected EOF
- the bash args object nested under the MCP tool's first parameter key (merged calls), e.g.
Reproducibility: serial tool calls (one per message) never failed in a ~2h session; parallel MCP+MCP calls also worked. The corruption appears specifically when a MCP tool call and a built-in tool call share the same assistant message.
Screenshot and/or share link
No response
Operating System
Linux
Terminal
Konsole
Activity
github-actions commentedon Oct 2, 2026
This issue might be a duplicate of an existing issue. Please check:
rekram1-node commentedon Oct 3, 2026
Recommend updating to v2:
https://opencode.ai/v2/docs
Also what model and what provider?
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊