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

Open
opened 2026-02-16 17:30:03 -05:00 by yindo · 10 comments
Owner

Originally created by @alexeypolitov on GitHub (Aug 11, 2025).

Originally assigned to: @thdxr on GitHub.

Image

https://opencode.ai/s/szC8qWz4

2025-08-11T041226.log.zip

Originally created by @alexeypolitov on GitHub (Aug 11, 2025). Originally assigned to: @thdxr on GitHub. <img width="1890" height="120" alt="Image" src="https://github.com/user-attachments/assets/995665cd-403f-4151-96d5-34b4e9e3eb22" /> https://opencode.ai/s/szC8qWz4 [2025-08-11T041226.log.zip](https://github.com/user-attachments/files/21709381/2025-08-11T041226.log.zip)
yindo added the model-problem label 2026-02-16 17:30:03 -05:00
Author
Owner

@alexeypolitov commented on GitHub (Aug 11, 2025):

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 commented on GitHub (Aug 11, 2025): 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
Author
Owner

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

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 commented on GitHub (Aug 11, 2025): this is likely issues on their end given the new model - give it a week and let me know if there are still problems
Author
Owner

@alexeypolitov commented on GitHub (Aug 11, 2025):

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 commented on GitHub (Aug 11, 2025): 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
Author
Owner

@alexeypolitov commented on GitHub (Aug 11, 2025):

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

Image
@alexeypolitov commented on GitHub (Aug 11, 2025): maybe, it's related to this settings. like some limit on bedrock, that unhandled by ai-sdk <img width="1463" height="263" alt="Image" src="https://github.com/user-attachments/assets/bc032e3c-93c3-4da8-bece-82a632e69ddb" />
Author
Owner

@ahmadomarr commented on GitHub (Sep 9, 2025):

@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 commented on GitHub (Sep 9, 2025): @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 '}' ```
Author
Owner

@barrenaedu commented on GitHub (Oct 8, 2025):

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 commented on GitHub (Oct 8, 2025): 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. <img width="3076" height="409" alt="Image" src="https://github.com/user-attachments/assets/1a07a2e4-753f-4f3b-8f23-666a0b621bf2" />
Author
Owner

@kevinw86 commented on GitHub (Dec 4, 2025):

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 commented on GitHub (Dec 4, 2025): 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
Author
Owner

@rekram1-node commented on GitHub (Dec 4, 2025):

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 commented on GitHub (Dec 4, 2025): 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
Author
Owner

@nachtgold commented on GitHub (Dec 16, 2025):

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 commented on GitHub (Dec 16, 2025): 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.
Author
Owner

@lfmunoz commented on GitHub (Jan 24, 2026):

I see same issue with Opus 4.5. Switch model to Sonnet 4.5, same error. gemini-3-pro-preview finally went through.

@thdxr don't blame the models, to me that that sounds HIGHLY brittle and a defeatist attitude . Change should have try catch and stick the response in some object. There should not be such thing as failing to parse response.
Edit: If is about the input or something complicated and you understand problem. Please describe problem better so someone smart or familiar comes up a solution. I.e, Guy who said try different model helped me a lot.

 ⚙ invalid [tool=write, error=Invalid input for tool write: JSON parsing failed: Text: {"filePath": "/home/XXX/git-       
 alpha/XXXX-com/src/pages/demo/page-bootstrap.vue".                                                                      
 Error message: JSON Parse error: Expected '}']                                                                             
                                                                                                                            
 ▣  Build · claude-opus-4.5 · 2m 9s                                                                                         


┃ go write

 ⚙ invalid [tool=write, error=Invalid input for tool write: JSON parsing failed: Text: {"filePath": "/home/XXXX/git-       
 alpha/XXXX-com/src/pages/demo/page-bootstrap.vue".                                                                      
 Error message: JSON Parse error: Expected '}']                                                                             
                                                                                                                            
 ▣  Build · claude-sonnet-4.5 · 1m 49s                                                                                      


┃ go write

@lfmunoz commented on GitHub (Jan 24, 2026): I see same issue with Opus 4.5. Switch model to Sonnet 4.5, same error. `gemini-3-pro-preview` finally went through. @thdxr don't blame the models, to me that that sounds HIGHLY brittle and a defeatist attitude . Change should have try catch and stick the response in some object. There should not be such thing as failing to parse response. Edit: If is about the input or something complicated and you understand problem. Please describe problem better so someone smart or familiar comes up a solution. I.e, Guy who said try different model helped me a lot. ⚙ invalid [tool=write, error=Invalid input for tool write: JSON parsing failed: Text: {"filePath": "/home/XXX/git- alpha/XXXX-com/src/pages/demo/page-bootstrap.vue". Error message: JSON Parse error: Expected '}'] ▣ Build · claude-opus-4.5 · 2m 9s ┃ ┃ go write ┃ ⚙ invalid [tool=write, error=Invalid input for tool write: JSON parsing failed: Text: {"filePath": "/home/XXXX/git- alpha/XXXX-com/src/pages/demo/page-bootstrap.vue". Error message: JSON Parse error: Expected '}'] ▣ Build · claude-sonnet-4.5 · 1m 49s ┃ ┃ go write
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1222