From 7fbf403a9fa2399b141e8df3a17edecce62e006b Mon Sep 17 00:00:00 2001 From: Dotta Date: Sat, 12 Sep 2026 13:37:40 -0500 Subject: [PATCH] fix: read cancellation evidence for keyed execution release Preserve operator-stop recovery suppression when newer callers release a run using only its company and run IDs. Co-Authored-By: Paperclip --- server/src/services/heartbeat.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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) {