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 <noreply@paperclip.ing>
This commit is contained in:
Dotta 2026-09-12 13:37:40 -05:00
parent 404ac6b228
commit 7fbf403a9f
1 changed files with 6 additions and 1 deletions

View File

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