Edits often corrupt files and agents have to restart all work #1683

Closed
opened 2026-02-16 17:32:08 -05:00 by yindo · 4 comments
Owner

Originally created by @divmgl on GitHub (Sep 10, 2025).

Originally assigned to: @thdxr on GitHub.

Happens with both Sonnet and Kimi K2. I'm unsure why this tends to happen, but the agents will often incorrectly edit files using Opencode's tools. I suspect there's a subtle bug in the replacing of text but I haven't been able to narrow it down. At first I thought it was only Kimi K2 but now it's happening with Claude as well. Makes OpenCode unusable.

Also want to highlight all of the other annoyances pointed out, like #2324 and #2536 which continue to pollute and destroy the context.

Another but is that cancelling does not work right away. Seems like this error has come back: #888

Originally created by @divmgl on GitHub (Sep 10, 2025). Originally assigned to: @thdxr on GitHub. Happens with both Sonnet and Kimi K2. I'm unsure why this tends to happen, but the agents will often incorrectly edit files using Opencode's tools. I suspect there's a subtle bug in the replacing of text but I haven't been able to narrow it down. At first I thought it was only Kimi K2 but now it's happening with Claude as well. Makes OpenCode unusable. Also want to highlight all of the other annoyances pointed out, like #2324 and #2536 which continue to pollute and destroy the context. Another but is that cancelling does not work right away. Seems like this error has come back: #888
yindo closed this issue 2026-02-16 17:32:08 -05:00
Author
Owner

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

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

  • #1261: Edit tool bug - ambiguous edits can lead to file corrupting (describes the same text replacement bug you suspect)
  • #1266: Bug: message history restoration corrupts text with attachments (another text corruption issue)
  • #2324: Cancelling causes context loss (referenced in your issue)
  • #888: press ESC again to interrupt does not work (cancellation issue you mentioned)

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

@github-actions[bot] commented on GitHub (Sep 10, 2025): This issue might be a duplicate of existing issues. Please check: - #1261: Edit tool bug - ambiguous edits can lead to file corrupting (describes the same text replacement bug you suspect) - #1266: Bug: message history restoration corrupts text with attachments (another text corruption issue) - #2324: Cancelling causes context loss (referenced in your issue) - #888: press ESC again to interrupt does not work (cancellation issue you mentioned) Feel free to ignore if none of these address your specific case.
Author
Owner

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

Very likely related to https://github.com/sst/opencode/issues/2433

Fixed by https://github.com/sst/opencode/pull/2534

@remorses commented on GitHub (Sep 11, 2025): Very likely related to https://github.com/sst/opencode/issues/2433 Fixed by https://github.com/sst/opencode/pull/2534
Author
Owner

@Shinobu-Kazahana commented on GitHub (Sep 11, 2025):

This is not fixed. cannot use the tool at all, every single edit tool call fails with "old string.." error. editing fails, and massive corruption. on latest update. using gemini 2.5 pro, was working fine on version from 3 days prior to this comment.

@Shinobu-Kazahana commented on GitHub (Sep 11, 2025): This is not fixed. cannot use the tool at all, every single edit tool call fails with "old string.." error. editing fails, and massive corruption. on latest update. using gemini 2.5 pro, was working fine on version from 3 days prior to this comment.
Author
Owner

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

[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

@rekram1-node commented on GitHub (Dec 27, 2025): [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1683