Skip to content

Commit 6ced1d2

Browse files
committed
fix: pause routines whose assigned agent is deleted
Unassigning alone left an active routine that could never dispatch. assertRoutineCanEnable already treats active-with-no-assignee as invalid, so the teardown was creating a state the service itself refuses to construct. Pause the routine as well, so the condition is visible instead of silent.
1 parent becb986 commit 6ced1d2

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

server/src/services/agents.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,14 @@ export function agentService(db: Db) {
747747
.update(issues)
748748
.set({ assigneeAgentId: null, createdByAgentId: null })
749749
.where(or(eq(issues.assigneeAgentId, id), eq(issues.createdByAgentId, id)));
750-
await tx.update(routines).set({ assigneeAgentId: null }).where(eq(routines.assigneeAgentId, id));
750+
// Pause as well as unassign. assertRoutineCanEnable already treats an
751+
// active routine with no assignee as invalid, so leaving it active would
752+
// create a state the service itself refuses to construct, and the routine
753+
// would silently never dispatch.
754+
await tx
755+
.update(routines)
756+
.set({ assigneeAgentId: null, status: "paused" })
757+
.where(eq(routines.assigneeAgentId, id));
751758
await tx.delete(heartbeatRunEvents).where(eq(heartbeatRunEvents.agentId, id));
752759
await tx.delete(agentTaskSessions).where(eq(agentTaskSessions.agentId, id));
753760
await tx.delete(activityLog).where(

0 commit comments

Comments
 (0)