Skip to content

Raw <tool_calls> markup in reasoning breaks tool calls on several models #25644

Closed as not planned

Description

@Zireael

Description

I’m seeing OpenCode produce raw <tool_calls>, <tool_call>, <tool_sep>, <arg_key>, and <arg_value> markup inside reasoning text. Once that happens, the following tool call can fail with a JSON parse error.

# invalid [tool=bash, error=Invalid input for tool bash: JSON parsing failed: Text: {"command": "git diff 94db11c..f503075 --stat</arg_value>\n<arg_key>description</arg_key>:\n<arg_value>Show files changed in the diff range</arg_value>\n.
Error message: JSON Parse error: Unterminated string]
The arguments provided to the tool are invalid: Invalid input for tool bash: JSON parsing failed: Text: {"command": "git diff 94db11c..f503075 --stat</arg_value>\n<arg_key>description</arg_key>:\n<arg_value>Show files changed in the diff range</arg_value>\n.
Error message: JSON Parse error: Unterminated string
[JSON PARSE ERROR - IMMEDIATE ACTION REQUIRED]
You sent invalid JSON arguments. The system could not parse your tool call.
STOP and do this NOW:
1. LOOK at the error message above to see what was expected vs what you sent.
2. CORRECT your JSON syntax (missing braces, unescaped quotes, trailing commas, etc).
3. RETRY the tool call with valid JSON.
DO NOT repeat the exact same invalid call.
Click to collapse
# invalid [tool=bash, error=Invalid input for tool bash: JSON parsing failed: Text: {"command": "git diff 94db11c..f503075 -- src/contracts.ts</arg_value>\n<arg_key>description</arg_key>:\n<arg_value>Show contracts.ts changes</arg_value>.
Error message: JSON Parse error: Unterminated string]
The arguments provided to the tool are invalid: Invalid input for tool bash: JSON parsing failed: Text: {"command": "git diff 94db11c..f503075 -- src/contracts.ts</arg_value>\n<arg_key>description</arg_key>:\n<arg_value>Show contracts.ts changes</arg_value>.
Error message: JSON Parse error: Unterminated string
[JSON PARSE ERROR - IMMEDIATE ACTION REQUIRED]
You sent invalid JSON arguments. The system could not parse your tool call.
STOP and do this NOW:
1. LOOK at the error message above to see what was expected vs what you sent.
2. CORRECT your JSON syntax (missing braces, unescaped quotes, trailing commas, etc).
3. RETRY the tool call with valid JSON.
DO NOT repeat the exact same invalid call.
Click to collapse
Thinking: I see the issue - the JSON is being malformed. Let me fix the tool calls with proper JSON syntax. The issue seems to be with the newline characters in the description field. Let me simplify and fix the JSON

I checked the session database and this is not limited to one model. In the current scan it shows up with big-pickle, hy3-preview-free, and z-ai/glm-5.1. Big Pickle started failing tool calls notoriously last few days. If it is currently secretly HY3, then there might be something wrong with that model.
I don’t think this is coming from the local encoder or from my plugins. I did several scans of the opencode source code and pluginns source codes that I have - nothing shows up in there that links to these failed tool calls. The bad tags seem to be already in the session data before Opencode tries to execute the tool.

Plugins

qartez-guard
oh-my-openagent
@slkiser/opencode-quota
@tarquinen/opencode-dcp
caveman-opencode-plugin
opencode-kilo-auth

OpenCode version

1.14.33

Steps to reproduce

  1. Start Opencode on Windows with the opencode provider.
  2. Use big-pickle, hy3-preview-free, or z-ai/glm-5.1.
  3. Ask it to do something that leads into a shell/tool call.
  4. At some point the assistant returns reasoning text that already contains raw <tool_calls> markup, and the next tool call can fail with JSON Parse error: Unterminated string.

Screenshot and/or share link

Image

Operating System

Windows 11

Terminal

Windows Terminal / PowerShell

Activity

  1. github-actions commented on May 3, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The issue body is completely empty — no template was used and no description was provided. Please use one of the issue templates (Bug Report, Feature Request, or Question) and fill in the required fields with details about the problem (description, steps to reproduce, OpenCode version, OS, etc.).

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. added
    needs:complianceThis means the issue will auto-close after 2 hours.
    and removed
    needs:complianceThis means the issue will auto-close after 2 hours.
    on May 3, 2026
  3. github-actions commented on May 3, 2026

    @github-actions
    Contributor

    Thanks for updating the issue! It now includes all the required information — a clear description, steps to reproduce, and system details. The compliance flag has been removed.

  4. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

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

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

Metadata

Metadata

Assignees

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