Skip to content

agent: tool calls intermittently rejected with "expected object, received string at the root" #54792

Open

Description

@meijin4

Summary

About half of all tool calls issued by the agent are rejected before execution with
The tool call arguments failed to parse: expected object, received string at the root.
The same call succeeds when replayed verbatim, which makes the failure rate look
random and causes severe productivity loss in long sessions.

Environment

  • opencode version: 2.0.27
  • OS: Windows_NT 10.0.26300 (win32 x64)
  • Terminal: Unavailable: terminal environment variables are not set
  • Shell: C:\WINDOWS\system32\cmd.exe (commands execute through pwsh)
  • Install/channel: latest
  • Active plugins: None found in config

Reproduction

  1. Start a long agent session that edits many files (tool calls: edit, write, shell, grep, read, execute).
  2. Issue tool calls with moderately complex string arguments (multi-line code with \n,
    escaped quotes \", accented characters, ${} template literals).
  3. Observe that a large share of calls are rejected at the parse layer without side effects.

Expected Behavior

Tool call arguments are parsed as a JSON object and the call executes.

Actual Behavior

The call is rejected with:

The tool call arguments failed to parse: expected object, received string at the root

Replaying the identical call succeeds, so the arguments are being emitted/delivered as a
raw string (truncated or double-encoded JSON) instead of an object.

Additional Context

  • Frequency: intermittent, roughly 40-60% of calls in a session (20+ occurrences observed).
  • Affected tools: edit, write, shell, grep, read, and Code Mode execute — not tool-specific,
    which points at the tool-call serialization/parsing layer rather than a single tool.
  • Payload correlation: long payloads with heavy escaping fail more often, but short and
    simple calls also fail occasionally.
  • Impact: no data corruption (a rejected call has no effect), but every rejection has to be
    replayed, which doubles the number of round-trips and is very disruptive.
  • Workaround in place: split work into very small calls and silently retry rejections.
  • Reproduced on the agent model "MiMo-V2.6-Pro" (provider opencode-go) through the
    OpenCode agent harness; a Code Mode catalog update occurred mid-session.
  • The error wording ("received string at the root") suggests the arguments arrive
    double-encoded (a JSON string containing the JSON object) or truncated mid-serialization.

Activity

  1. opencode-agent commented on Oct 12, 2026

    @opencode-agent
    Contributor

    Thanks for the report! It reads like it was written by the agent itself, so before we try to reproduce it, could you tell us briefly, in your own words:

    • Where the error appears: in the TUI as a failed tool call, as a session or provider error, or only in the model's own text? A screenshot would help a lot.
    • The exact error text, copied from OpenCode's output rather than paraphrased by the model. We couldn't find the message The tool call arguments failed to parse: expected object, received string at the root in OpenCode 2.x itself, so it may come from the provider (opencode-go) or from the model.
    • Other models: does it also happen with a model other than MiMo-V2.6-Pro, or a provider other than opencode-go?
    • Logs covering a few failing calls, from opencode.log in OpenCode's log directory (on Windows, under your user profile). If you can, also include an export of a short session where it happens. Please remove API keys and anything sensitive first.

    You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know you're done.

    These existing issues are related, ordered from most to least likely to cover your problem, in case one of them already does:

  2. meijin4 commented on Oct 12, 2026

    @meijin4
    Author

    Thanks for the report! It reads like it was written by the agent itself, so before we try to reproduce it, could you tell us briefly, in your own words:

    * **Where the error appears:** in the TUI as a failed tool call, as a session or provider error, or only in the model's own text? A screenshot would help a lot.
    
    * **The exact error text**, copied from OpenCode's output rather than paraphrased by the model. We couldn't find the message `The tool call arguments failed to parse: expected object, received string at the root` in OpenCode 2.x itself, so it may come from the provider (opencode-go) or from the model.
    
    * **Other models:** does it also happen with a model other than `MiMo-V2.6-Pro`, or a provider other than `opencode-go`?
    
    * **Logs** covering a few failing calls, from `opencode.log` in OpenCode's log directory (on Windows, under your user profile). If you can, also include an export of a short session where it happens. Please remove API keys and anything sensitive first.
    

    You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know you're done.

    These existing issues are related, ordered from most to least likely to cover your problem, in case one of them already does:

    * [mimo-v2.5 (opencode-go) tool calls fail with "upstream response contained invalid tool calls #43185](https://github.com/anomalyco/opencode/issues/43185): MiMo models on opencode-go fail tool calls with "upstream response contained invalid tool calls"
    
    * [[bug] openai-compatible (custom provider): intermittent 400 "Assistant tool call function.arguments must be a JSON object" — freshest tool-call arguments sent non-object right after tool result (self-heals on retry) #54025](https://github.com/anomalyco/opencode/issues/54025): intermittent "tool call arguments must be a JSON object" errors that went away on retry
    
    * [tool calls: arguments corrupt across calls and schema-invalid calls can execute #47902](https://github.com/anomalyco/opencode/issues/47902): tool call arguments corrupted across calls in a long v2 session on Windows
    
    * [zen/go: mimo-v2.5 tool calls return 400 (Provider returned error) #43481](https://github.com/anomalyco/opencode/issues/43481): MiMo tool calls returning 400 on Zen/Go
    
    • Image
    • I get no error messages, it justed crash and says that my answers is ready.

    • Not tested with another model for the moment.

    • Didn't find any relevant logs.

  3. opencode-agent commented on Oct 12, 2026

    @opencode-agent
    Contributor

    Thanks for following up! Unfortunately the screenshot didn't load on our side, so could you paste the text it shows as a code block?

    So the actual problem is that the agent stops in the middle of a task with no error and just says the answer is ready, not the failed to parse error in the original report? To narrow it down, could you share:

    • Steps: what you asked it to do (roughly), and whether it also happens in a fresh, short session or only in long ones.
    • Another model: if you can, try the same task with a different model (on opencode-go or another provider) and tell us whether it still stops early. That tells us whether this is specific to MiMo-V2.6-Pro.
    • Logs: run opencode debug paths log to see where the log files are. Please attach the most recent log covering a run where it stopped, after removing API keys and anything sensitive.
    • Session export: opencode session list shows session IDs; opencode session export <id> --sanitize > session.json exports one with sensitive content redacted. Please attach it for a session where it stopped early.

    These existing issues may be related, most likely first:

  4. meijin4 commented on Oct 12, 2026

    @meijin4
    Author
    • First, I asked to correct a visual bug. Then everytime it calls tools, it crashed. No matter what I asked, encountered the same issue when tools are called.
    • Happened with Kimi K3 too.
  5. opencode-agent commented on Oct 12, 2026

    @opencode-agent
    Contributor

    Thanks for the extra details! I tried this on 2.0.27 with a simulated model. I asked it to fix a visual bug in a CSS file, and the model called the read tool. The tool ran and the agent kept going afterwards, both with normal arguments and with arguments sent as a JSON string, which is what your original error points to. The turn didn't end early.

    So OpenCode itself handles tool calls normally here. What I couldn't test is the real opencode-go models (MiMo-V2.6-Pro, Kimi K3) on Windows, which is where you see it. That needs a maintainer with opencode-go access to try.

    If you'd like to help narrow it down meanwhile:

    • Does it also happen with a model from a different provider, not opencode-go?
    • After a turn stops, opencode session export <id> --sanitize > session.json (get the ID with opencode session list) records how the step finished. Attaching that file would show whether the provider ended the response early.

    Possibly related: #41469 (the session stops silently after an empty response from opencode-go) and #43185 (MiMo tool calls fail on opencode-go).

  6. meijin4 commented on Oct 13, 2026

    @meijin4
    Author

    session-export-ses_eead15d82ffe-clean.json

    • Here is the session export.
    • You'll also find the logs from opencode.log when an issue appear.

    opencode-logs-cleaned.txt

    Note: Opened a new tab, tested with GLM 5.3 Flash, it seems to work for the moment.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions