fix: close websocket turns after errors

This commit is contained in:
chengyongru
2026-06-01 23:00:53 +08:00
committed by Xubin Ren
parent ebc8c9faf9
commit 0042f68f94
3 changed files with 49 additions and 1 deletions
+8 -1
View File
@@ -45,13 +45,13 @@ from nanobot.security.workspace_access import (
bind_workspace_scope,
reset_workspace_scope,
)
from nanobot.session import turn_continuation
from nanobot.session.goal_state import (
goal_state_runtime_lines,
runner_wall_llm_timeout_s,
sustained_goal_active,
)
from nanobot.session.manager import Session, SessionManager
from nanobot.session import turn_continuation
from nanobot.utils.document import extract_documents, reference_non_image_attachments
from nanobot.utils.helpers import image_placeholder_text
from nanobot.utils.helpers import truncate_text as truncate_text_fn
@@ -1017,6 +1017,13 @@ class AgentLoop:
channel=msg.channel, chat_id=msg.chat_id,
content="Sorry, I encountered an error.",
))
if not turn_continuation.internal_continuation_pending(msg.metadata):
await self._runtime_events().turn_completed(
channel=msg.channel,
chat_id=msg.chat_id,
session_key=session_key,
metadata=msg.metadata,
)
finally:
# Drain any messages still in the pending queue and re-publish
# them to the bus so they are processed as fresh inbound messages