Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(files): treat BOM-only text as empty
chengyongrua721806a5091
diff --git a/nanobot/agent/tools/filesystem.py b/nanobot/agent/tools/filesystem.pyindex 6f680bb05..0b9469549 100644--- a/nanobot/agent/tools/filesystem.py+++ b/nanobot/agent/tools/filesystem.py@@ -375,6 +375,9 @@ class ReadFileTool(_FsTool):"Only supported text files and images can be read.")+ if not text_content:+ return f"(Empty file: {path})"+# Normalize CRLF -> LF before line-splitting. Primarily a Windows# concern (git checkouts with autocrlf, editors saving CRLF) but# applied on all platforms so downstream StrReplace/Grep behaviordiff --git a/tests/tools/test_read_enhancements.py b/tests/tools/test_read_enhancements.pyindex b5fddefdb..5e3c91bbc 100644--- a/tests/tools/test_read_enhancements.py+++ b/tests/tools/test_read_enhancements.py@@ -138,6 +138,16 @@ class TestReadDedup:assert "2| Second line" in resultassert "\x00" not in result+ @pytest.mark.parametrize("encoding", ["utf-8-sig", "utf-16", "utf-32"])+ @pytest.mark.asyncio+ async def test_bom_only_unicode_text_is_empty_file(self, tool, tmp_path, encoding):+ f = tmp_path / "empty.txt"+ f.write_bytes("".encode(encoding))++ result = await tool.execute(path=str(f))++ assert result == f"(Empty file: {f})"+# ---------------------------------------------------------------------------# Cross-session isolation (issue #3571)