fix(files): honor Unicode byte-order marks

This commit is contained in:
Zihan Xu authored and chengyongru committed 2026-09-23 00:29:52 +08:00
1 parent 602efc3bc3
commit 394b4f2cc3
1 file changed
+4
+4
View File
@@ -348,6 +348,10 @@ class ReadFileTool(_FsTool):
fp, offset=offset, limit=limit, content_hash=content_hash, fp, offset=offset, limit=limit, content_hash=content_hash,
): ):
return f"[File unchanged since last read: {path}]" return f"[File unchanged since last read: {path}]"
from nanobot.utils.document import _decode_bom_text
text_content = _decode_bom_text(raw)
if text_content is None:
try: try:
text_content = raw.decode("utf-8") text_content = raw.decode("utf-8")
except UnicodeDecodeError: except UnicodeDecodeError: