Disable BlockAnchorReplacer for better edit tool #1612

Closed
opened 2026-02-16 17:31:45 -05:00 by yindo · 3 comments
Owner

Originally created by @remorses on GitHub (Sep 5, 2025).

Originally assigned to: @thdxr on GitHub.

Currently opencode fails a lot more often than Claude Code when doing edits. With fails I mean the output has syntax errors. I think this is caused by the tool BlockAnchorReplacer string replacement tool
https://github.com/sst/opencode/blob/8426a0d59502844345516b8ca3d6d91b4e6aec90/packages/opencode/src/tool/edit.ts#L600

opencode often does a string replacement and it inserts double ending branches, causing syntax errors, it then tries to do another search and replace to fix it and it gets an error "search and replament cannot be the same"

Often Claude will try to make a string replacement with an incorrect search string and opencode will accept the search string anyway and cause a syntax error, usually because of double ending brackets. I think this is caused by the BlockAnchorReplacer tool.

Originally created by @remorses on GitHub (Sep 5, 2025). Originally assigned to: @thdxr on GitHub. Currently opencode fails a lot more often than Claude Code when doing edits. With fails I mean the output has syntax errors. I think this is caused by the tool `BlockAnchorReplacer` string replacement tool https://github.com/sst/opencode/blob/8426a0d59502844345516b8ca3d6d91b4e6aec90/packages/opencode/src/tool/edit.ts#L600 opencode often does a string replacement and it inserts double ending branches, causing syntax errors, it then tries to do another search and replace to fix it and it gets an error "search and replament cannot be the same" Often Claude will try to make a string replacement with an incorrect search string and opencode will accept the search string anyway and cause a syntax error, usually because of double ending brackets. I think this is caused by the `BlockAnchorReplacer` tool.
yindo closed this issue 2026-02-16 17:31:45 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Sep 5, 2025):

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

  • #2255: Both issues relate to edit tool reliability problems, though #2255 focuses on spurious error messages while this issue addresses BlockAnchorReplacer causing syntax errors

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

@github-actions[bot] commented on GitHub (Sep 5, 2025): This issue might be a duplicate of existing issues. Please check: - #2255: Both issues relate to edit tool reliability problems, though #2255 focuses on spurious error messages while this issue addresses BlockAnchorReplacer causing syntax errors Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Sep 11, 2025):

fixed by: https://github.com/sst/opencode/commit/4ccf6835274d9bceed426b767c3464822c076b9d

@rekram1-node commented on GitHub (Sep 11, 2025): fixed by: https://github.com/sst/opencode/commit/4ccf6835274d9bceed426b767c3464822c076b9d
Author
Owner

@remorses commented on GitHub (Sep 12, 2025):

opencode is as good as Claude Code finally, I also had to disable all formatters and LSP

@remorses commented on GitHub (Sep 12, 2025): opencode is as good as Claude Code finally, I also had to disable all formatters and LSP
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1612