Skip to content

Your lightweight open-source personal agent.

fix(documents): preserve universal newlines

Zihan Xue48f1ae65b7b
diff --git a/nanobot/utils/document.py b/nanobot/utils/document.py
index 136e9e73f..7e9727ab3 100644
--- a/nanobot/utils/document.py
+++ b/nanobot/utils/document.py
@@ -626,6 +626,7 @@ def _extract_text_file(path: Path) -> str:
content = raw.decode("utf-8")
except UnicodeDecodeError:
content = raw.decode("latin-1")
+ content = content.replace("\r\n", "\n").replace("\r", "\n")
return _truncate(content, _MAX_TEXT_LENGTH)
except Exception as e:
logger.exception("Failed to read text file {}", path)