mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-04 02:01:48 +03:00
feat(runtime): add user-controlled turn recovery
This commit is contained in:
@@ -43,6 +43,7 @@ from nanobot.runtime_context import public_history_message
|
||||
from nanobot.session.goal_state import goal_state_ws_blob
|
||||
from nanobot.session.history_visibility import is_hidden_history_message
|
||||
from nanobot.session.manager import Session, SessionManager
|
||||
from nanobot.session.recovery import RecoveryCoordinator
|
||||
from nanobot.session.session_handles import session_handle_for_name
|
||||
from nanobot.session.session_messages import (
|
||||
SessionMessageEnvelope,
|
||||
@@ -511,6 +512,7 @@ class WebuiTurnCoordinator:
|
||||
bus: MessageBus
|
||||
sessions: SessionManager
|
||||
schedule_background: Callable[[Awaitable[None]], None]
|
||||
recovery: RecoveryCoordinator | None = None
|
||||
|
||||
def subscribe(self, runtime_events: RuntimeEventBus) -> Callable[[], None]:
|
||||
"""Subscribe this coordinator to runtime events."""
|
||||
@@ -654,6 +656,8 @@ class WebuiTurnCoordinator:
|
||||
event.runtime.context_window_tokens if event.runtime is not None else None
|
||||
),
|
||||
)
|
||||
if self.recovery is not None:
|
||||
await self.recovery.turn_completed(event.context.session_key)
|
||||
self._schedule_title_update_from_event(event)
|
||||
|
||||
async def _handle_goal_state_changed(self, event: GoalStateChanged) -> None:
|
||||
|
||||
Reference in New Issue
Block a user