Tool.edit should recieve json object #4165

Open
opened 2026-02-16 17:42:52 -05:00 by yindo · 1 comment
Owner

Originally created by @xihale on GitHub (Jan 4, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

I found LLM is likely to pass json type content to write .json files, thus they directly pass json object to edit tool, however, the tool doesn't parse it well, which waste many tokens to change themselves' ways to stringify it (which is likely to make mistakens) or use cat << EOF fallback.

Plugins

oh my opencode

OpenCode version

1.0.203

Steps to reproduce

  1. just let LLM write a json file may reproduce it.

Screenshot and/or share link

Image

Operating System

6.12.63-1-MANJARO

Terminal

Ghostty

Originally created by @xihale on GitHub (Jan 4, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description I found LLM is likely to pass json type content to write .json files, thus they directly pass json object to edit tool, however, the tool doesn't parse it well, which waste many tokens to change themselves' ways to stringify it (which is likely to make mistakens) or use `cat << EOF` fallback. ### Plugins oh my opencode ### OpenCode version 1.0.203 ### Steps to reproduce 1. just let LLM write a json file may reproduce it. ### Screenshot and/or share link <img width="1069" height="465" alt="Image" src="https://github.com/user-attachments/assets/d14a6d24-aecf-4120-b92d-4e1a36565443" /> ### Operating System 6.12.63-1-MANJARO ### Terminal Ghostty
yindo added the bug label 2026-02-16 17:42:52 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 4, 2026):

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

  • #5890: Incomplete JSON when writing out files
  • #6281: Can't use Claude Opus 4.5 on opencode using Github Copilot (same JSON parsing error)
  • #2188: JSON parsing failed with incomplete JSON
  • #5362: Write Tool includes metadata in output and created filecontent
  • #2002: JSON Parse error: Expected '}' with truncated JSON
  • #266: gemini doesn't handle edit tool very well (parameter handling)

All of these issues relate to JSON parsing failures and tool parameter handling when LLMs attempt to pass JSON objects directly to the edit/write tools.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 4, 2026): This issue might be a duplicate of existing issues. Please check: - #5890: Incomplete JSON when writing out files - #6281: Can't use Claude Opus 4.5 on opencode using Github Copilot (same JSON parsing error) - #2188: JSON parsing failed with incomplete JSON - #5362: Write Tool includes metadata in output and created filecontent - #2002: JSON Parse error: Expected '}' with truncated JSON - #266: gemini doesn't handle edit tool very well (parameter handling) All of these issues relate to JSON parsing failures and tool parameter handling when LLMs attempt to pass JSON objects directly to the edit/write tools. Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4165