[BUG]

Resolved 💬 2 comments Opened Jun 17, 2026 by beepgx909 Closed Jun 20, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Incident Summary for Anthropic Support

Date: June 16, 2026
Product: Claude Code (claude-sonnet-4-6)
---
What happened:

During a session where I was making edits to chat_alerts.py, Claude Code's Edit tool introduced Unicode encoding
corruption into the file. The file is UTF-8 encoded and contains special characters (em-dashes —, box-drawing
characters, arrows →).

When Claude applied an edit that replaced a large block of code in _scan_history and _stream_thread, the replacement
text came back with curly/smart quotes (", ", ', ') substituted in place of straight ASCII quotes (", '). This caused
an immediate SyntaxError when Python tried to compile the file.

Claude then attempted to fix this by running a Python script to replace curly quotes with straight quotes. However,
this script re-wrote the file and in doing so corrupted the multi-byte UTF-8 sequences for the existing em-dash
characters (U+2014, encoded as 0xE2 0x80 0x94), turning them into garbled byte sequences (0xC3 0xA2 0xE2 0x82 0xAC).
This produced a second, deeper SyntaxError on a different line (line 753).

At that point the file was unrecoverable by patching. Claude ran git checkout HEAD -- chat_alerts.py to restore the
file, which wiped all legitimate changes made during the session, requiring the entire feature implementation to be
rebuilt from scratch.

---
Root cause:

The Edit tool injected curly/smart quotes into Python source code. This is a Claude Code tool bug — the model's output
or the tool's text handling substituted typographic quotes for ASCII quotes in the replacement string.

---
Usage impact:

The error and its cascading recovery attempts (multiple patch scripts, file reads, compile checks, agent delegation to
rebuild all changes) consumed approximately 20% of the user's available Claude Code usage for the billing period —
usage that produced no useful output and was entirely caused by the tool error.

---
Request:

Usage credit or refund for the tokens consumed by the error recovery cycle.

What Should Happen?

Edit the code without deleting the entire commit.

Error Messages/Logs

Steps to Reproduce

Not sure

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.84

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Windows Terminal

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗