From 58658afaa43bbe03a468033a148a4eb2d3d8fc6f Mon Sep 17 00:00:00 2001 From: Minh Vu Date: Thu, 25 Jun 2026 21:48:58 +0200 Subject: [PATCH] Report UTF-8 byte length in write tool --- src/anthropic/lib/tools/agent_toolset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/anthropic/lib/tools/agent_toolset.py b/src/anthropic/lib/tools/agent_toolset.py index d771996a..083e09aa 100644 --- a/src/anthropic/lib/tools/agent_toolset.py +++ b/src/anthropic/lib/tools/agent_toolset.py @@ -544,7 +544,7 @@ async def write(file_path: str, content: str) -> str: target.write_text(content) except OSError as e: raise _fs_error("write", file_path, e) from e - return f"wrote {len(content)} bytes to {file_path}" + return f"wrote {len(content.encode(\"utf-8\"))} bytes to {file_path}" return write