From 2a0d5f90949f406410a8ff1c275fc49eee1bf747 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 4 Apr 2026 11:45:46 +0100 Subject: [PATCH] fix(ci): remove duplicated heartbeat prompt setup --- src/infra/heartbeat-runner.ts | 53 +++++++++++------------------------ 1 file changed, 17 insertions(+), 36 deletions(-) diff --git a/src/infra/heartbeat-runner.ts b/src/infra/heartbeat-runner.ts index b5a7251858f..9615e7f9bfb 100644 --- a/src/infra/heartbeat-runner.ts +++ b/src/infra/heartbeat-runner.ts @@ -642,42 +642,6 @@ export async function runHeartbeatOnce(opts: { // sending the full conversation history (~100K tokens) to the LLM. // Delivery routing still uses the main session entry (lastChannel, lastTo). const useIsolatedSession = heartbeat?.isolatedSession === true; - const canRelayToUser = Boolean( - delivery.channel !== "none" && delivery.to && visibility.showAlerts, - ); - const workspaceDir = resolveAgentWorkspaceDir(cfg, agentId); - const { prompt, hasExecCompletion, hasCronEvents } = resolveHeartbeatRunPrompt({ - cfg, - heartbeat, - preflight, - canRelayToUser, - workspaceDir, - startedAt, - heartbeatFileContent: preflight.heartbeatFileContent, - }); - - // If no tasks are due, skip heartbeat entirely (including isolated session creation) - if (prompt === null) { - return { status: "skipped", reason: "no-tasks-due" }; - } - - let runSessionKey = sessionKey; - let runStorePath = storePath; - if (useIsolatedSession) { - const isolatedKey = `${sessionKey}:heartbeat`; - const cronSession = resolveCronSession({ - cfg, - sessionKey: isolatedKey, - agentId, - nowMs: startedAt, - forceNew: true, - }); - cronSession.store[isolatedKey] = cronSession.sessionEntry; - await saveSessionStore(cronSession.storePath, cronSession.store); - runSessionKey = isolatedKey; - runStorePath = cronSession.storePath; - } - const delivery = resolveHeartbeatDeliveryTarget({ cfg, entry, @@ -734,6 +698,23 @@ export async function runHeartbeatOnce(opts: { return { status: "skipped", reason: "no-tasks-due" }; } + let runSessionKey = sessionKey; + let runStorePath = storePath; + if (useIsolatedSession) { + const isolatedKey = `${sessionKey}:heartbeat`; + const cronSession = resolveCronSession({ + cfg, + sessionKey: isolatedKey, + agentId, + nowMs: startedAt, + forceNew: true, + }); + cronSession.store[isolatedKey] = cronSession.sessionEntry; + await saveSessionStore(cronSession.storePath, cronSession.store); + runSessionKey = isolatedKey; + runStorePath = cronSession.storePath; + } + // Update task last run times AFTER successful heartbeat completion const updateTaskTimestamps = async () => { if (!preflight.tasks || preflight.tasks.length === 0) {