refactor: store cron origin delivery context

This commit is contained in:
chengyongru
2026-06-12 15:07:25 +08:00
parent b232a52794
commit 5ae907bc2f
10 changed files with 171 additions and 96 deletions
+4 -4
View File
@@ -980,7 +980,7 @@ def _run_gateway(
from nanobot.bus.runtime_events import RuntimeEventBus
from nanobot.channels.manager import ChannelManager
from nanobot.cron.service import CronService
from nanobot.cron.session_delivery import bound_session_inbound_context
from nanobot.cron.session_delivery import origin_delivery_context
from nanobot.cron.session_turns import (
CRON_DEFER_UNTIL_IDLE_META,
CRON_TRIGGER_META,
@@ -1046,12 +1046,12 @@ def _run_gateway(
)
def _bound_session_delivery_context(
session_key: str,
job: CronJob,
*,
turn_seed: str,
source_label: str | None,
) -> tuple[str, str, dict[str, Any]]:
channel, chat_id, metadata = bound_session_inbound_context(session_key)
channel, chat_id, metadata = origin_delivery_context(job)
if channel == "websocket":
metadata["webui"] = True
@@ -1086,7 +1086,7 @@ def _run_gateway(
prompt_ref = _cron_prompt_ref(prompt)
run_id = f"{job.id}:{int(time.time() * 1000)}:{uuid.uuid4().hex[:8]}"
channel, chat_id, metadata = _bound_session_delivery_context(
session_key,
job,
turn_seed=f"cron:{job.id}",
source_label=job.name,
)