From 69d60e2b063b1b5b649a97320b36d8b7612b7f8a Mon Sep 17 00:00:00 2001 From: chengyongru Date: Fri, 10 Apr 2026 18:03:36 +0800 Subject: [PATCH] fix(agent): handle UnicodeDecodeError in _read_last_entry history.jsonl may contain non-UTF-8 bytes (e.g. from email channel binary content), causing auto compact to fail when reading the last entry for summary generation. Catch UnicodeDecodeError alongside FileNotFoundError and JSONDecodeError. --- nanobot/agent/memory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nanobot/agent/memory.py b/nanobot/agent/memory.py index 26c5cd45f..e9662ff2c 100644 --- a/nanobot/agent/memory.py +++ b/nanobot/agent/memory.py @@ -290,7 +290,7 @@ class MemoryStore: if not lines: return None return json.loads(lines[-1]) - except (FileNotFoundError, json.JSONDecodeError): + except (FileNotFoundError, json.JSONDecodeError, UnicodeDecodeError): return None def _write_entries(self, entries: list[dict[str, Any]]) -> None: