


























@@ -46,6 +46,7 @@ import {
4646createCronRunDiagnosticsFromError,
4747mergeCronRunDiagnostics,
4848} from "../run-diagnostics.js";
49+import { resolveCronAbortReasonText } from "../service/execution-errors.js";
4950import type {
5051CronAgentExecutionPhaseUpdate,
5152CronAgentExecutionStarted,
@@ -341,6 +342,7 @@ function resolveCronSourceDeliveryPlan(params: {
341342 target,
342343messageToolEnabled: true,
343344messageToolForced: false,
345+requireExplicitMessageTarget: true,
344346requireExplicitMessageTargetEvidence: true,
345347directFallback: true,
346348skipFallbackWhenMessageToolSentToTarget: params.resolvedDelivery.ok,
@@ -425,14 +427,16 @@ function appendCronDeliveryInstruction(params: {
425427deliveryRequested: boolean;
426428messageToolEnabled: boolean;
427429resolvedDeliveryOk: boolean;
430+requireExplicitMessageTarget: boolean;
428431}) {
429432if (!params.deliveryRequested) {
430433return params.commandBody;
431434}
432435if (params.messageToolEnabled) {
433-const targetHint = params.resolvedDeliveryOk
434- ? "for the current chat"
435- : "with an explicit target";
436+const targetHint =
437+params.requireExplicitMessageTarget || !params.resolvedDeliveryOk
438+ ? "with an explicit target"
439+ : "for the current chat";
436440return `${params.commandBody}\n\nUse the message tool if you need to notify the user directly ${targetHint}. If you do not send directly, your final plain-text reply will be delivered automatically.`.trim();
437441}
438442return `${params.commandBody}\n\nReturn your response as plain text; it will be delivered automatically. If the task explicitly calls for messaging a specific external recipient, note who/where it should go instead of sending it yourself.`.trim();
@@ -833,6 +837,7 @@ async function prepareCronRunContext(params: {
833837toolsAllow: agentPayload?.toolsAllow,
834838}),
835839resolvedDeliveryOk: resolvedDelivery.ok,
840+requireExplicitMessageTarget: sourceDelivery.messageTool.requireExplicitTarget,
836841});
837842838843const skillsSnapshot = await resolveCronSkillsSnapshot({
@@ -1271,12 +1276,8 @@ export async function runCronIsolatedAgentTurn(params: {
12711276const admittedLifecycleGeneration = getAgentEventLifecycleGeneration();
12721277const abortSignal = params.abortSignal ?? params.signal;
12731278const isAborted = () => abortSignal?.aborted === true;
1274-const abortReason = () => {
1275-const reason = abortSignal?.reason;
1276-return typeof reason === "string" && reason.trim()
1277- ? reason.trim()
1278- : "cron: job execution timed out";
1279-};
1279+const abortReason = () =>
1280+resolveCronAbortReasonText(abortSignal?.reason) ?? "cron: job execution timed out";
12801281const isFastTestEnv = process.env.OPENCLAW_TEST_FAST === "1";
12811282const prepared = await prepareCronRunContext({ input: params, isFastTestEnv });
12821283if (!prepared.ok) {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。