refactor(memory): simplify read_unprocessed_history cursor guard
Replace verbose loop with one-liner list comprehension using
e.get("cursor", 0) to handle missing cursor keys.
This commit is contained in:
@@ -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*."""
|
||||
|
||||
Reference in New Issue
Block a user