fix(ci): remove duplicated heartbeat prompt setup

This commit is contained in:
Peter Steinberger
2026-04-04 11:45:46 +01:00
parent c5c5c77ebb
commit 2a0d5f9094

View File

@@ -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) {