-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Description
When using claude-code-acp with an ACP client that implements readTextFile, the Edit tool fails
with:
Error: The provided old_string does not appear in the file: "..."
Even when the file clearly contains the text. (I tried .html but also .txt)
Reproduction steps:
- Connect an ACP client that implements readTextFile and writeTextFile
- Ask Claude to edit a file (e.g., "change the title in index.html from X to Y")
- Claude reads the file successfully
- Claude attempts to edit → fails with the above error
Root cause:
Two issues:
Root cause #1 - Caching condition never true:
- https://github.com/zed-industries/claude-code-acp/blob/main/src/acp-agent.ts#L624 - The condition
!params.limit && !params.line is never satisfied - https://github.com/zed-industries/claude-code-acp/blob/main/src/mcp-server.ts#L106-L111 - Read
tool defaults that cause the issue:
offset: z.number().optional().default(1),
limit: z.number().optional().default(defaults.linesToRead),
Root cause #2 - Unhandled exception:
- https://github.com/zed-industries/claude-code-acp/blob/main/src/acp-agent.ts#L662-L666 - First
unhandled toolInfoFromToolUse() call - https://github.com/zed-industries/claude-code-acp/blob/main/src/acp-agent.ts#L729-L733 - Second
unhandled toolInfoFromToolUse() call
Where the actual error is thrown:
- https://github.com/zed-industries/claude-code-acp/blob/main/src/mcp-server.ts#L671 -
replaceAndCalculateLocation throws when old_string not found - https://github.com/zed-industries/claude-code-acp/blob/main/src/tools.ts#L113-L114 - Uses
cachedFileContent[path] || "" (empty string when not cached)
Fix branch: https://github.com/0bserver07/claude-code-acp/tree/fix/edit-tool-cache-bug
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Status
Bugs