opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[aws bedrock: anthropic opus 4.1] The arguments provided to the tool are invalid: Invalid input for tool write: JSON parsing failed: Text

Open alexeypolitov opened this issue 5 months ago • 9 comments

Image

https://opencode.ai/s/szC8qWz4

2025-08-11T041226.log.zip

alexeypolitov avatar Aug 11 '25 04:08 alexeypolitov

looks like this problem not only with write tool, but it like streaming at all for opus 4.1 in bedrock. I like stop streaming on a middle. reproduce only on large write operations. Not reproduce for opus 4. only for opus 4.1

alexeypolitov avatar Aug 12 '25 02:08 alexeypolitov

this is likely issues on their end given the new model - give it a week and let me know if there are still problems

thdxr avatar Aug 12 '25 02:08 thdxr

for share, I did try to use bedrock due openrouter. maybe I not completely understand how openrouter works, but in opencode, opus 4.1 on bedrock due openrouter was pretty fast and have no some steaming-like problems

alexeypolitov avatar Aug 12 '25 03:08 alexeypolitov

maybe, it's related to this settings. like some limit on bedrock, that unhandled by ai-sdk

Image

alexeypolitov avatar Aug 12 '25 03:08 alexeypolitov

@thdxr I am still facing this issue

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

ahmadomarr avatar Sep 09 '25 04:09 ahmadomarr

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 17:10 barrenaedu

invalid [tool=write, error=Invalid input for tool write: JSON parsing failed: Text: {"filePath": "C:\Users\Project_Design_Document.md". Error message: JSON Parse error: Expected '}']

how can i fix this

kevinw86 avatar Dec 04 '25 13:12 kevinw86

This is the model calling a tool incorrectly, it should be able to recover on it's own. It called a tool with invalid json, it just has to try again generally

rekram1-node avatar Dec 04 '25 17:12 rekram1-node

I get it, when the content is to long (with Copilot). Then I prompt, that it should write in chunks and then the document could be written.

nachtgold avatar Dec 16 '25 12:12 nachtgold