
























@@ -1,3 +1,4 @@
1+/** Orchestrates isolated cron agent turn setup, execution, delivery, and cleanup. */
12import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
23import { retireSessionMcpRuntime } from "../../agents/agent-bundle-mcp-tools.js";
34import { hasAnyAuthProfileStoreSource } from "../../agents/auth-profiles/source-check.js";
@@ -269,6 +270,8 @@ function buildCronDeliveryTrace(params: {
269270fallbackUsed: boolean;
270271delivered: boolean;
271272}): CronDeliveryTrace {
273+// Trace both intended and resolved targets so run logs can explain fallback
274+// delivery without leaking provider-specific raw routing internals.
272275const intended = normalizeCronTraceTarget({
273276channel: params.deliveryPlan.channel ?? "last",
274277to: params.deliveryPlan.to ?? null,
@@ -305,6 +308,7 @@ function resolveCronSourceDeliveryPlan(params: {
305308threadId: params.resolvedDelivery.threadId,
306309};
307310if (params.deliveryPlan.mode === "webhook") {
311+// Webhook jobs do not expose chat delivery or message-tool fallback.
308312return createSourceDeliveryPlan({
309313owner: "none",
310314reason: "cron_webhook",
@@ -313,6 +317,8 @@ function resolveCronSourceDeliveryPlan(params: {
313317});
314318}
315319if (params.deliveryPlan.mode === "none") {
320+// delivery=none still allows explicit message-tool sends from the agent,
321+// but cron itself must not auto-announce a final reply.
316322return createSourceDeliveryPlan({
317323owner: "none",
318324reason: "cron_none",
@@ -693,6 +699,8 @@ async function prepareCronRunContext(params: {
693699.slice(selectedPreflightCandidateIndex + 1)
694700.map((candidate) => `${candidate.provider}/${candidate.model}`)
695701 : undefined;
702+// When preflight skips the first local candidate, trim the fallback chain so
703+// execution starts at the reachable provider and only falls forward from it.
696704if (selectedPreflightCandidate && modelFallbacksOverride) {
697705if (firstUnavailablePreflight?.status === "unavailable") {
698706logWarn(
@@ -837,6 +845,8 @@ async function prepareCronRunContext(params: {
837845 : await (
838846await loadCronAuthProfileRuntime()
839847).resolveSessionAuthProfileOverride({
848+// Auth profile resolution can mutate session state; pass the same
849+// store and key that persistence will later write.
840850cfg: cfgWithAgentDefaults,
841851 provider,
842852acceptedProviderIds: listOpenAIAuthProfileProvidersForAgentRuntime({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。