mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-05 10:41:58 +03:00
refactor(agent): make checkpoint recovery ownership explicit
This commit is contained in:
@@ -1466,7 +1466,7 @@ class AgentLoop:
|
||||
try:
|
||||
key = self._effective_session_key(msg)
|
||||
session = self.sessions.get_or_create(key)
|
||||
if self._restore_runtime_checkpoint(session):
|
||||
if restore_runtime_checkpoint(session):
|
||||
self._clear_pending_user_turn(session)
|
||||
self.sessions.save(session)
|
||||
logger.info(
|
||||
@@ -1823,7 +1823,7 @@ class AgentLoop:
|
||||
if ctx.kind is TurnKind.USER:
|
||||
self.workspace_scopes.persist_message_scope(session, msg)
|
||||
|
||||
if self._restore_runtime_checkpoint(session):
|
||||
if restore_runtime_checkpoint(session):
|
||||
self.sessions.save(session)
|
||||
if (
|
||||
RECOVERY_INBOUND_METADATA_KEY not in msg.metadata
|
||||
@@ -2313,10 +2313,6 @@ class AgentLoop:
|
||||
if self._RUNTIME_CHECKPOINT_KEY in session.metadata:
|
||||
session.metadata.pop(self._RUNTIME_CHECKPOINT_KEY, None)
|
||||
|
||||
def _restore_runtime_checkpoint(self, session: Session) -> bool:
|
||||
"""Materialize an unfinished turn into session history before a new request."""
|
||||
return restore_runtime_checkpoint(session)
|
||||
|
||||
async def process_direct(
|
||||
self,
|
||||
content: str,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""Durable, side-effect-safe recovery for interrupted WebUI turns.
|
||||
|
||||
The coordinator owns restart policy. AgentLoop only exposes checkpoint
|
||||
materialization and an admission hook, so transport code never has to guess
|
||||
whether an interrupted tool call is safe to replay.
|
||||
The coordinator owns restart policy. Checkpoint materialization is a session
|
||||
operation shared with AgentLoop lifecycle boundaries, so transport code never
|
||||
has to guess whether an interrupted tool call is safe to replay.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
Reference in New Issue
Block a user