JSON Parse error: Expected '}' with the write tool after updating to v0.5.5 Description #1336

Closed
opened 2026-02-16 17:30:29 -05:00 by yindo · 4 comments
Owner

Originally created by @behavio1 on GitHub (Aug 16, 2025).

Originally assigned to: @thdxr on GitHub.

Since updating to OpenCode version 0.5.5, I am encountering a persistent error when the agent attempts to use the write tool. The operation consistently fails with a JSON parsing error.

Error message:

Write

The arguments provided to the tool are invalid: Invalid input for tool write: JSON parsing
failed: Text: {"filePath":
"/Users/M***/*****.md".
Error message: JSON Parse error: Expected '}'

As shown the filePath string being passed to the write tool appears to be truncated. This results in an incomplete and malformed JSON object, which lacks the closing double quote for the file path and the final closing curly brace }. This malformed JSON is causing the JSON Parse error.
This issue seems to be a regression introduced in version 0.5.5, as this functionality was working correctly in previous versions. This bug is critical as it prevents the agent from creating or modifying files.

Steps to Reproduce

  • Update to OpenCode version 0.5.5.
  • Assign a task that requires the agent to write to a file with a relatively long file path.
  • Observe the write tool failing with the "JSON Parse error: Expected '}'" message.

Expected Behavior
The write tool should receive a complete and valid JSON object, allowing it to successfully write to the specified file.

Originally created by @behavio1 on GitHub (Aug 16, 2025). Originally assigned to: @thdxr on GitHub. Since updating to OpenCode version 0.5.5, I am encountering a persistent error when the agent attempts to use the write tool. The operation consistently fails with a JSON parsing error. Error message: ``` Write The arguments provided to the tool are invalid: Invalid input for tool write: JSON parsing failed: Text: {"filePath": "/Users/M***/*****.md". Error message: JSON Parse error: Expected '}' ``` As shown the filePath string being passed to the write tool appears to be truncated. This results in an incomplete and malformed JSON object, which lacks the closing double quote for the file path and the final closing curly brace }. This malformed JSON is causing the JSON Parse error. This issue seems to be a regression introduced in version 0.5.5, as this functionality was working correctly in previous versions. This bug is critical as it prevents the agent from creating or modifying files. Steps to Reproduce - Update to OpenCode version 0.5.5. - Assign a task that requires the agent to write to a file with a relatively long file path. - Observe the write tool failing with the "JSON Parse error: Expected '}'" message. Expected Behavior The write tool should receive a complete and valid JSON object, allowing it to successfully write to the specified file.
yindo closed this issue 2026-02-16 17:30:29 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 16, 2025):

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

  • #1803: Both report JSON parsing failures with the write tool, specifically "Invalid input for tool write: JSON parsing failed" errors

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

@github-actions[bot] commented on GitHub (Aug 16, 2025): This issue might be a duplicate of existing issues. Please check: - #1803: Both report JSON parsing failures with the write tool, specifically "Invalid input for tool write: JSON parsing failed" errors Feel free to ignore if none of these address your specific case.
Author
Owner

@thdxr commented on GitHub (Aug 16, 2025):

what model is this?

@thdxr commented on GitHub (Aug 16, 2025): what model is this?
Author
Owner

@behavio1 commented on GitHub (Aug 18, 2025):

Claude Sonnet 4. I restarted my computer and now it works better - this issue is not appearing anymore so far.

@behavio1 commented on GitHub (Aug 18, 2025): Claude Sonnet 4. I restarted my computer and now it works better - this issue is not appearing anymore so far.
Author
Owner

@jayair commented on GitHub (Aug 18, 2025):

Closing this then

@jayair commented on GitHub (Aug 18, 2025): Closing this then
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1336