opencode icon indicating copy to clipboard operation
opencode copied to clipboard

JSON parsing failed: Text

Open bb33bb opened this issue 4 months ago • 15 comments

Write

The arguments provided to the tool are invalid: Invalid input for tool write: JSON parsing failed: Text:
{"filePath": "/Volumes/4t/Deep Multi-Task and Meta Learning/01/main.py".
Error message: JSON Parse error: Expected '}'

bb33bb avatar Aug 22 '25 23:08 bb33bb

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

  • #2002: Similar JSON parse error 'Expected '}' with the write tool after updating to v0.5.5
  • #1803: Similar JSON parsing error with AWS Bedrock - 'The arguments provided to the tool are invalid: Invalid input for tool write: JSON parsing failed'
  • #1278: Similar 'JSON Parse error: Unterminated string' issue with openrouter/kimi-k2

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

github-actions[bot] avatar Aug 22 '25 23:08 github-actions[bot]

this is the llm failing to call the tool looks like, this can happen from time to time, some models are worse than others.

What model was it?

rekram1-node avatar Aug 22 '25 23:08 rekram1-node

duplicated, sorry github claude 4 model

this is the llm failing to call the tool looks like, this can happen from time to time, some models are worse than others.

What model was it?

bb33bb avatar Aug 22 '25 23:08 bb33bb

Write

The arguments provided to the tool are invalid: Invalid input for tool write: Type validation failed: Value:
{}.
Error message: [
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "undefined",
    "path": [
      "filePath"
    ],
    "message": "Required"

Write

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

bb33bb avatar Aug 31 '25 00:08 bb33bb

I’m experiencing a similar issue. It seems that this model, specifically the GitHub Claude 4 one, has recurring problems.

JacobHolman avatar Sep 09 '25 18:09 JacobHolman

I’m experiencing a similar issue. It seems that this model, specifically the GitHub Claude 4 one, has recurring problems.

I am using the same model.

bb33bb avatar Sep 10 '25 05:09 bb33bb

Same error here, using opencode 0.14.6 and LM Studio 0.3.29 with qwen/qwen3-coder-30b. If I use qwen/qwen2.5-coder-14b the error is not present.

Image

barrenaedu avatar Oct 08 '25 18:10 barrenaedu

yeah looks like lm studio issue : https://github.com/lmstudio-ai/lmstudio-bug-tracker/issues/1071

rekram1-node avatar Oct 08 '25 19:10 rekram1-node

Fixed in LM Studio 0.3.30, sorry about that

yagil avatar Oct 08 '25 23:10 yagil

It's ok, just a comment in case anyone needed more information about versions,etc... Thank you

barrenaedu avatar Oct 09 '25 00:10 barrenaedu

Happening with copilot and opus 4.5

vasilvestre avatar Nov 28 '25 13:11 vasilvestre

I am also started having this issue last week from nowhere. Also using GitHub Copilot models. In my case Sonnet 4.5

brpaz avatar Dec 20 '25 12:12 brpaz

@brpaz can u share session?

Note that normally this is the model/provider emitting incomplete tool calls

rekram1-node avatar Dec 20 '25 18:12 rekram1-node

opencode export > session.json

rekram1-node avatar Dec 20 '25 18:12 rekram1-node

Sorry. I think I don´t have that session anymore.

In the meantime, I found some Github Issue that mentioned that this happens when the contents of the file are too big. asking the model to write to the file in chunks seems to have fixed the issue.

If this happens agian I will save the session and share here.

brpaz avatar Dec 21 '25 15:12 brpaz