fix: strengthen cron heartbeat multi-payload suppression (#32131) (thanks @adhishthite)

This commit is contained in:
Peter Steinberger
2026-03-02 22:15:58 +00:00
parent 2330c71b63
commit 7253e91300
3 changed files with 24 additions and 2 deletions

View File

@@ -116,6 +116,27 @@ describe("runCronIsolatedAgentTurn", () => {
});
});
it("suppresses announce delivery for multi-payload narration ending in HEARTBEAT_OK", async () => {
await withTempHome(async (home) => {
const { storePath, deps } = await createTelegramDeliveryFixture(home);
mockEmbeddedAgentPayloads([
{ text: "Checked inbox and calendar. Nothing actionable yet." },
{ text: "HEARTBEAT_OK" },
]);
const res = await runTelegramAnnounceTurn({
home,
storePath,
deps,
});
expect(res.status).toBe("ok");
expect(res.delivered).toBe(false);
expect(deps.sendMessageTelegram).not.toHaveBeenCalled();
expect(runSubagentAnnounceFlow).not.toHaveBeenCalled();
});
});
it("handles media heartbeat delivery and announce cleanup modes", async () => {
await withTempHome(async (home) => {
const { storePath, deps } = await createTelegramDeliveryFixture(home);

View File

@@ -87,8 +87,8 @@ export function pickLastDeliverablePayload(payloads: DeliveryPayload[]) {
}
/**
* Check if all payloads are just heartbeat ack responses (HEARTBEAT_OK).
* Returns true if delivery should be skipped because there's no real content.
* Check if delivery should be skipped because the agent signaled no user-visible update.
* Returns true when any payload is a heartbeat ack token and no payload contains media.
*/
export function isHeartbeatOnlyResponse(payloads: DeliveryPayload[], ackMaxChars: number) {
if (payloads.length === 0) {