mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 18:31:10 +00:00
fix(cron): treat embedded error payloads as run failures
(cherry picked from commit 50fd31c070)
This commit is contained in:
committed by
Peter Steinberger
parent
75969ed5c4
commit
8c8374defa
@@ -543,6 +543,25 @@ export async function runCronIsolatedAgentTurn(params: {
|
||||
(deliveryPayload?.mediaUrls?.length ?? 0) > 0 ||
|
||||
Object.keys(deliveryPayload?.channelData ?? {}).length > 0;
|
||||
const deliveryBestEffort = resolveCronDeliveryBestEffort(params.job);
|
||||
const hasErrorPayload = payloads.some((payload) => payload?.isError === true);
|
||||
const lastErrorPayloadText = [...payloads]
|
||||
.toReversed()
|
||||
.find((payload) => payload?.isError === true && Boolean(payload?.text?.trim()))
|
||||
?.text?.trim();
|
||||
const embeddedRunError = hasErrorPayload
|
||||
? (lastErrorPayloadText ?? "cron isolated run returned an error payload")
|
||||
: undefined;
|
||||
const resolveRunOutcome = (params?: { delivered?: boolean }) =>
|
||||
withRunSession({
|
||||
status: hasErrorPayload ? "error" : "ok",
|
||||
...(hasErrorPayload
|
||||
? { error: embeddedRunError ?? "cron isolated run returned an error payload" }
|
||||
: {}),
|
||||
summary,
|
||||
outputText,
|
||||
delivered: params?.delivered,
|
||||
...telemetry,
|
||||
});
|
||||
|
||||
// Skip delivery for heartbeat-only responses (HEARTBEAT_OK with no real content).
|
||||
const ackMaxChars = resolveHeartbeatAckMaxChars(agentCfg);
|
||||
@@ -586,11 +605,14 @@ export async function runCronIsolatedAgentTurn(params: {
|
||||
withRunSession,
|
||||
});
|
||||
if (deliveryResult.result) {
|
||||
return deliveryResult.result;
|
||||
if (!hasErrorPayload || deliveryResult.result.status !== "ok") {
|
||||
return deliveryResult.result;
|
||||
}
|
||||
return resolveRunOutcome({ delivered: deliveryResult.result.delivered });
|
||||
}
|
||||
const delivered = deliveryResult.delivered;
|
||||
summary = deliveryResult.summary;
|
||||
outputText = deliveryResult.outputText;
|
||||
|
||||
return withRunSession({ status: "ok", summary, outputText, delivered, ...telemetry });
|
||||
return resolveRunOutcome({ delivered });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user