fix: guard run completion boundary

This commit is contained in:
ZacharyZhang-NY committed 2026-04-23 20:34:31 -04:00
1 parent 245586a9aa
commit d21edb244f
6 files changed
+268 -8

No files matched your search

@@ -71,9 +71,6 @@ export function finalizeRun(
leaseRenewalMap.delete(event.runId);
const runOutcome = db.core.runs.finishRun({ ...event, unattributedCost });
if (run.workspaceId) {
db.core.workspaces.releaseWorkspaceLock(run.workspaceId, run.id);
}
db.core.activity.addActivity({
companyId: run.companyId,
actor: run.agentId,
@@ -86,6 +83,15 @@ export function finalizeRun(
return { run, task, runOutcome };
}
export function releaseCompletedRunWorkspaceLock(
rfCtx: RunFinishedContext | null,
deps: Pick<HandlerDeps, "db">,
): void {
const workspaceId = rfCtx?.run.workspaceId;
if (!workspaceId) return;
deps.db.core.workspaces.releaseWorkspaceLock(workspaceId, rfCtx.run.id);
}
export function accumulateAndRotateSession(
event: RunFinishedEvent,
deps: HandlerDeps,