saoudrizwan / claude-dev

Autonomous coding agent right in your IDE, capable of creating/editing files, executing commands, and more with your permission every step of the way.
https://marketplace.visualstudio.com/items?itemName=saoudrizwan.claude-dev
MIT License
4.04k stars 381 forks source link

Stuck in "Claude tried to use write_to_file for 'path' without value for required parameter 'content'" Loop #146

Closed brentpope closed 1 week ago

brentpope commented 3 weeks ago

Claude-dev is getting stuck in a loop where it will do the first few responses correctly - including waiting for user to approve the next step. Then it will start making api calls without user input, then will start repeating the last call over and over until the limit is reached. The message box is unavailable so I can't ctrl-c to stop and just have to wait until the limit is reached. When the limit is reached the only option is to reset the counter and continue, which just keeps looping on the same request. The only real option is to wait until the limit is reached and then start a new task which looses all my work. This has happened using Anthropic Sonet 3.5 and Open Router with deepseek.

I know there has been a recent update, so is this a bug? or should I just remove claude-dev and reinstall?

greylio commented 3 weeks ago

This is also my experience as of a couple of hours ago. Do you get an error message? Mine is as follows: "Claude tried to use write_to_file for 'FILEPATH\FILENAME' without value for required parameter 'content'. This is likely due to output token limits. Retrying..." but where FILEPATH\FILENAME is the path and filename that it's trying to edit. Much looping. I'm using Amazon Bedrock anthropic.claude-3-5-sonnet-20240620-v1:0 . Max tokens on this model is only 200k, so I'm wondering if there's a mismatch. I understand it could be related to overuse but I can't find mention of the error anywhere else.

saoudrizwan commented 3 weeks ago

There hasn't been any recent updates that would cause this. This usually happens when you are working with large files, so I recommend breaking your file down into smaller separate files. Anthropic is releasing Fast Edit Mode which should make applying edits to large files much faster and more stable.

You can try installing an older version of the extension (Marketplace > Claude Dev > the Uninstall button has an option "Install another version") so it might be worth seeing if you can replicate the issue with a previous version you were on.

mkearl commented 3 weeks ago

This has been doing this for quite a while even in older versions.

mkearl commented 3 weeks ago

This especially happens when using open router and deepseek

thebigelf1 commented 2 weeks ago

I continue to struggle with this as well. It's not just large files, I've had it happen on very small files unfortunately.

marksolly commented 2 weeks ago

I think this issue is a duplicate of https://github.com/saoudrizwan/claude-dev/issues/127. It occurs when the model generates output larger than the output token limit. You could try adding the following to the custom instructions in the claud-dev settings:

- If error "Error: Missing value for required parameter 'content'" is seen, output a diff of required code changes instead of using the write_to_file tool.

Seems like a bug as it's something that could be detected and mitigated by asking Claude for a smaller output. Someone else also made a pull request which is relevant: https://github.com/saoudrizwan/claude-dev/pull/158.

thebigelf1 commented 2 weeks ago

You could try adding the following to the custom instructions in the claud-dev settings:

- If error "Error: Missing value for required parameter 'content'" is seen, output a diff of required code changes instead of using the write_to_file tool.

I tried this and some other variants of an instruction, but unfortunately it didn't help.

dillycone commented 2 weeks ago

Same issue here...hope you can fix this, please. Thanks.

brentpope commented 2 weeks ago

I never saw the 'Claude tried to use write_to_file_for_path' error, all I saw was an api request repeating over and over. Tried again and here is the detail: { "model": "deepseek/deepseek-coder", "max_tokens": 4096, "system": "(see SYSTEM_PROMPT in src/ClaudeDev.ts)", "messages": [ { "conversation_history": "..." }, { "role": "user", "content": [ { "type": "text", "text": "If you have completed the user's task, use the attempt_completion tool. If you require additional information from the user, use the ask_followup_question tool. Otherwise, if you have not completed the task and do not need additional information, then proceed with the next step of the task. (This is an automated message, so do not respond to it conversationally.)" } ] } ], "tools": "(see tools in src/ClaudeDev.ts)", "tool_choice": "auto" }

saoudrizwan commented 1 week ago

Working on figuring this out, please see my comment here https://github.com/saoudrizwan/claude-dev/issues/127