mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-06 17:55:59 +00:00
fix: only advance dream_cursor on completed batches to prevent silent loss
This commit is contained in:
parent
c30e4d86f3
commit
9fa90b1034
@ -974,12 +974,10 @@ class Dream:
|
|||||||
if event["status"] == "ok":
|
if event["status"] == "ok":
|
||||||
changelog.append(f"{event['name']}: {event['detail']}")
|
changelog.append(f"{event['name']}: {event['detail']}")
|
||||||
|
|
||||||
# Advance cursor — always, to avoid re-processing Phase 1
|
# Only advance cursor on successful completion to prevent silent loss
|
||||||
new_cursor = batch[-1]["cursor"]
|
|
||||||
self.store.set_last_dream_cursor(new_cursor)
|
|
||||||
self.store.compact_history()
|
|
||||||
|
|
||||||
if result and result.stop_reason == "completed":
|
if result and result.stop_reason == "completed":
|
||||||
|
new_cursor = batch[-1]["cursor"]
|
||||||
|
self.store.set_last_dream_cursor(new_cursor)
|
||||||
logger.info(
|
logger.info(
|
||||||
"Dream done: {} change(s), cursor advanced to {}",
|
"Dream done: {} change(s), cursor advanced to {}",
|
||||||
len(changelog), new_cursor,
|
len(changelog), new_cursor,
|
||||||
@ -987,10 +985,12 @@ class Dream:
|
|||||||
else:
|
else:
|
||||||
reason = result.stop_reason if result else "exception"
|
reason = result.stop_reason if result else "exception"
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Dream incomplete ({}): cursor advanced to {}",
|
"Dream incomplete ({}): cursor NOT advanced, will retry next cron cycle",
|
||||||
reason, new_cursor,
|
reason,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.store.compact_history()
|
||||||
|
|
||||||
# Git auto-commit (only when there are actual changes)
|
# Git auto-commit (only when there are actual changes)
|
||||||
if changelog and self.store.git.is_initialized():
|
if changelog and self.store.git.is_initialized():
|
||||||
ts = batch[-1]["timestamp"]
|
ts = batch[-1]["timestamp"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user