fix(channels): retain scheduled results across pre-send outages

This commit is contained in:
Xubin Ren committed 2026-10-17 12:49:03 +08:00
1 parent 61db036cee
commit 508cedff31
31 files changed
+768 -61

No files matched your search

+6 -1
View File
@@ -14,6 +14,7 @@ from nanobot.agent.tools.base import Tool, ToolResult, tool_parameters
from nanobot.agent.tools.context import ToolContext, current_request_context
from nanobot.agent.tools.path_utils import resolve_workspace_path
from nanobot.agent.tools.schema import ArraySchema, StringSchema, tool_parameters_schema
from nanobot.bus.delivery import DeliveryRequest
from nanobot.bus.events import OutboundMessage
from nanobot.config.paths import get_workspace_path
from nanobot.security.workspace_access import current_tool_workspace
@@ -236,6 +237,9 @@ class MessageTool(Tool):
media=media or [],
buttons=button_rows or [],
metadata=metadata,
delivery=(DeliveryRequest.from_context(
default_metadata, request_ctx.session_key, request_ctx.session_generation,
) if request_ctx is not None else None),
)
if self._suppress_delivery_var.get():
@@ -253,6 +257,7 @@ class MessageTool(Tool):
if button_rows
else ""
)
return f"Message sent to {channel}:{chat_id}{media_info}{button_info}"
action = "queued" if msg.delivery is not None else "sent"
return f"Message {action} to {channel}:{chat_id}{media_info}{button_info}"
except Exception as e:
return ToolResult.error(f"Error sending message: {str(e)}")
+7
View File
@@ -9,6 +9,7 @@ from copy import deepcopy
from dataclasses import dataclass, field
from typing import TYPE_CHECKING, Any, cast
from nanobot.bus.delivery import DeliveryRequest
from nanobot.bus.events import InboundMessage, OutboundMessage
from nanobot.bus.notification_delivery import notification_is_deliverable
from nanobot.bus.outbound_events import (
@@ -341,6 +342,12 @@ class TurnDelivery:
"response_sources": [dataclasses.asdict(self._response_source)],
})
if response.channel != "websocket" or stop_reason != "error":
delivery = DeliveryRequest.from_context(
self.input_message.metadata, self.session_key,
self.delivery_message.session_generation,
)
if delivery is not None:
response = dataclasses.replace(response, delivery=delivery)
await self.bus.publish_outbound(response)
elif self.lifecycle_message.channel == "cli":
await self.bus.publish_outbound(