fix(filesystem): correct write success message from bytes to characters

len(content) counts Unicode code points, not UTF-8 bytes. For non-ASCII
content such as Chinese or emoji, the reported count would be lower than
the actual bytes written to disk, which is misleading to the agent.
This commit is contained in:
Leo fu 2026-04-06 12:12:34 -04:00 committed by Xubin Ren
parent cefeddab8e
commit 44c7992095

View File

@ -186,7 +186,7 @@ class WriteFileTool(_FsTool):
fp = self._resolve(path)
fp.parent.mkdir(parents=True, exist_ok=True)
fp.write_text(content, encoding="utf-8")
return f"Successfully wrote {len(content)} bytes to {fp}"
return f"Successfully wrote {len(content)} characters to {fp}"
except PermissionError as e:
return f"Error: {e}"
except Exception as e: