diff --git a/server/src/services/heartbeat.ts b/server/src/services/heartbeat.ts index 34625f8022..ecf655a357 100644 --- a/server/src/services/heartbeat.ts +++ b/server/src/services/heartbeat.ts @@ -25344,11 +25344,16 @@ export function heartbeatService( options: { suppressImmediateRecovery?: boolean } = {}, ) { try { + // Some release paths carry only the durable run key. Read authoritative + // cancellation evidence before deciding whether automatic recovery is allowed. + const latestRun = options.suppressImmediateRecovery ? null : await getRun(run.id); + const operatorCancelled = latestRun?.companyId === run.companyId + && isOperatorCancelledRun(latestRun, latestRun.agentId); const { postCommitEffects } = await wakeQueue.releaseIssueExecution({ companyId: run.companyId, runId: run.id, now: new Date(), - suppressImmediateRecovery: options.suppressImmediateRecovery || isOperatorCancelledRun(run, run.agentId), + suppressImmediateRecovery: options.suppressImmediateRecovery || operatorCancelled, }); await applyWakeQueuePostCommitEffects(postCommitEffects); } catch (error) {