mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 05:54:43 +00:00
fix(cron): avoid marking queued announce paths as delivered (#29716)
Cron announce flow treated queued/steered outcomes as delivered even when no direct outbound send was confirmed, which could report false-positive delivery state. This change keeps cron delivery strict: only direct-path announce results count as delivered. Closes #29660
This commit is contained in:
@@ -1064,6 +1064,32 @@ describe("subagent announce formatting", () => {
|
||||
expect(params.accountId).toBe("kev");
|
||||
});
|
||||
|
||||
it("does not report cron announce as delivered when it was only queued", async () => {
|
||||
embeddedRunMock.isEmbeddedPiRunActive.mockReturnValue(true);
|
||||
embeddedRunMock.isEmbeddedPiRunStreaming.mockReturnValue(false);
|
||||
sessionStore = {
|
||||
"agent:main:main": {
|
||||
sessionId: "session-cron-queued",
|
||||
lastChannel: "telegram",
|
||||
lastTo: "123",
|
||||
queueMode: "collect",
|
||||
queueDebounceMs: 0,
|
||||
},
|
||||
};
|
||||
|
||||
const didAnnounce = await runSubagentAnnounceFlow({
|
||||
childSessionKey: "agent:main:subagent:test",
|
||||
childRunId: "run-cron-queued",
|
||||
requesterSessionKey: "main",
|
||||
requesterDisplayKey: "main",
|
||||
announceType: "cron job",
|
||||
...defaultOutcomeAnnounce,
|
||||
});
|
||||
|
||||
expect(didAnnounce).toBe(false);
|
||||
expect(agentSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("keeps queued idempotency unique for same-ms distinct child runs", async () => {
|
||||
embeddedRunMock.isEmbeddedPiRunActive.mockReturnValue(true);
|
||||
embeddedRunMock.isEmbeddedPiRunStreaming.mockReturnValue(false);
|
||||
|
||||
@@ -1346,7 +1346,17 @@ export async function runSubagentAnnounceFlow(params: {
|
||||
directIdempotencyKey,
|
||||
signal: params.signal,
|
||||
});
|
||||
didAnnounce = delivery.delivered;
|
||||
// Cron delivery state should only be marked as delivered when we have a
|
||||
// direct path result. Queue/steer means "accepted for later processing",
|
||||
// not a confirmed channel send, and can otherwise produce false positives.
|
||||
if (
|
||||
announceType === "cron job" &&
|
||||
(delivery.path === "queued" || delivery.path === "steered")
|
||||
) {
|
||||
didAnnounce = false;
|
||||
} else {
|
||||
didAnnounce = delivery.delivered;
|
||||
}
|
||||
if (!delivery.delivered && delivery.path === "direct" && delivery.error) {
|
||||
defaultRuntime.error?.(
|
||||
`Subagent completion direct announce failed for run ${params.childRunId}: ${delivery.error}`,
|
||||
|
||||
Reference in New Issue
Block a user