[BUG] `Write` tool intermittently corrupts files with Cyrillic characters and emoji

Resolved 💬 3 comments Opened Aug 22, 2025 by Xpos587 Closed Aug 26, 2025

Environment

  • Platform (select one):
  • [X] Anthropic API (via Claude Code max subscription)
  • Claude CLI version: 1.0.88 (Claude Code)
  • Operating System: Artix Linux (rolling)
  • Terminal: foot 1.23.1-1.1

Bug Description

The built-in Write tool intermittently corrupts files containing Cyrillic characters. The output becomes garbled, suggesting a UTF-8 encoding error during the write process. This makes generating non-English documentation unreliable.

This occurs on Linux and seems related to, but distinct from, Issue #6246 (which is specific to Windows hooks).

I cannot reliably determine the trigger; some files with Cyrillic text write correctly, while others do not. The presence of complex Markdown and emoji (e.g., 🚀, 🤖) in the text might be a contributing factor, but this is just a hypothesis.

Steps to Reproduce

  1. Instruct an agent (main or sub-agent) to write a multi-line .md file containing a mix of Cyrillic text, Markdown formatting, and emoji.
  2. Let the agent execute the Write tool.
  3. Inspect the output file for character corruption.
  4. Note: The bug does not occur on every attempt, which makes isolating the exact cause difficult.

Expected Behavior

The output file should contain the exact, uncorrupted Cyrillic text and emoji as generated by the agent.

Actual Behavior

The file sometimes contains garbled text, such as @825B, <8@! MB> B5AB., where Cyrillic characters have been replaced.

Additional Context

This is a significant blocker for non-English workflows. Analysis of the session log files (*.jsonl) confirms the agent generates a correct UTF-8 string in its context; the corruption appears to happen specifically within the Write tool's execution.

{
    //...
    "message": {
        "content": [
            {
                "type": "tool_use",
                "id": "toolu_012VJBfXEWpvWm3x5nhrgNfL",
                "name": "Write",
                "input": {
                    "file_path": "~/Github/podvoram-rf/.memory/index.md",
                    "content": "# База Знаний Проекта ПоДворам.рф\n\n## 📖 Описание проекта\n\n**ПоДворам.рф** — сайт для прямых продаж..."
                }
            }
        ]
    }
    //...
}

<img width="1280" height="408" alt="Image" src="https://github.com/user-attachments/assets/a589e91e-7198-43ad-bcdf-d3f88f7ffebb" />

View original on GitHub ↗

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