From 79a0fd8ed0af0e31c2c213cc3e9f9ab58af62d56 Mon Sep 17 00:00:00 2001 From: nanobot Date: Tue, 28 Jul 2026 14:13:23 +0800 Subject: [PATCH] fix: capture pending_user_turn before _restore_runtime_checkpoint clears it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _restore_runtime_checkpoint() clears both the runtime_checkpoint and pending_user_turn flags (lines 1966-1967). recover_stale_sessions() checked had_pending AFTER calling it, so had_pending was always False when a checkpoint existed. This meant the re-publish of the last user message never happened — the user got a notification but the interrupted turn was never re-triggered. --- nanobot/agent/loop.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nanobot/agent/loop.py b/nanobot/agent/loop.py index b5fe774c..001009bb 100644 --- a/nanobot/agent/loop.py +++ b/nanobot/agent/loop.py @@ -2063,7 +2063,12 @@ class AgentLoop: try: session = self.sessions.get_or_create(key) changed = False - had_pending = False + # Capture pending flag before _restore_runtime_checkpoint + # clears it (it clears both checkpoint and pending_turn at + # lines 1966-1967). + had_pending = bool( + session.metadata.get(self._PENDING_USER_TURN_KEY) + ) if self._restore_runtime_checkpoint(session): changed = True if self._restore_pending_user_turn(session):