You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
invalid [tool=write, error=Invalid input for tool write: JSON parsing failed:
Error message: JSON Parse error: Expected '}’
I simply asked the agent to complete a project, and it started writing code on its own, which then frequently resulted in this error.
Once this happens, the agent will continuously report errors and retry writing, getting stuck in an infinite loop and unable to continue working. It seems unaware that the write tool call failed.
This issue occurs with both Gemini3 (flash or pro) and Claude (4.5 or 4.6). Why is this?
Plugins
oh-my-opencode-slim, opencode-dcp
OpenCode version
1.1.53
Steps to reproduce
1.ask agent to write a project.
2.Randomly, when writing to a file, it occurs.
I've encountered this error in the past and the cause of this is most likely that the agent is trying to write more than the model's output token limit (the global default is set to 32K tokens in opencode).
You could try getting the model to write in smaller chunks or if not setting OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX to a higher value to see if that solves the issue.
Reacted by minicybersheep, Chindriș Mihai - Alexandru, tensility, Piotr Franczyk and Ming Wang
I've encountered this error in the past and the cause of this is most likely that the agent is trying to write more than the model's output token limit (the global default is set to 32K tokens in opencode).
You could try getting the model to write in smaller chunks or if not setting OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX to a higher value to see if that solves the issue.
Activity
github-actions commentedon Feb 6, 2026
This issue might be a duplicate of existing issues. Please check:
Error message: JSON Parse error: Unterminated stringerrors #10755: JSON Parse error: Unterminated string during normal operation with gpt-5.2-codexThese issues share your core symptoms:
Feel free to ignore if your specific case differs, but these likely share the same root cause.
NachoFLizaur commentedon Feb 6, 2026
I've encountered this error in the past and the cause of this is most likely that the agent is trying to write more than the model's output token limit (the global default is set to 32K tokens in opencode).
You could try getting the model to write in smaller chunks or if not setting OPENCODE_EXPERIMENTAL_OUTPUT_TOKEN_MAX to a higher value to see if that solves the issue.
Starlight0798 commentedon Feb 6, 2026
thanks, i will try
github-actions commentedon Apr 8, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.