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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user