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.
This commit is contained in:
chengyongru 2026-04-10 18:03:36 +08:00 committed by Xubin Ren
parent fb6dd111e1
commit 69d60e2b06

View File

@ -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: