Skip to content

Your lightweight open-source personal agent.

refactor(memory): simplify read_unprocessed_history cursor guard

chengyongru524c097f76bb
diff --git a/nanobot/agent/memory.py b/nanobot/agent/memory.py
index bed1b6d3e..66da912fb 100644
--- a/nanobot/agent/memory.py
+++ b/nanobot/agent/memory.py
@@ -245,15 +245,7 @@ class MemoryStore:
def read_unprocessed_history(self, since_cursor: int) -> list[dict[str, Any]]:
"""Return history entries with cursor > *since_cursor*."""
- entries = []
- for e in self._read_entries():
- cursor = e.get("cursor")
- if cursor is None:
- logger.warning("Skipping history entry without cursor: {}", e.get("timestamp", "unknown"))
- continue
- if cursor > since_cursor:
- entries.append(e)
- return entries
+ return [e for e in self._read_entries() if e.get("cursor", 0) > since_cursor]
def compact_history(self) -> None:
"""Drop oldest entries if the file exceeds *max_history_entries*."""