feat(KB-161): terminate active agent sessions on engine pause
- Add enginePaused agent termination to executor (kills sessions, moves tasks back to todo) - Add enginePaused agent termination to triage processor (kills sessions, clears specifying status) - Update enginePaused JSDoc to reflect new termination behavior vs old graceful drain - Add unit tests for executor/triage pause termination and integration tests for restart flow - Include changeset for engine pause behavior change
This commit is contained in:
@@ -172,7 +172,7 @@ export class TaskExecutor {
|
||||
* Listens for `task:moved` to auto-execute tasks moved to `in-progress`,
|
||||
* `task:updated` to terminate agent sessions when individual tasks are paused,
|
||||
* and `settings:updated` to terminate **all** active agent sessions when
|
||||
* `globalPause` transitions from `false` to `true` (emergency stop).
|
||||
* `globalPause` or `enginePaused` transitions from `false` to `true`.
|
||||
* Paused tasks are moved back to `todo` rather than marked as `failed`.
|
||||
*/
|
||||
constructor(
|
||||
@@ -208,6 +208,18 @@ export class TaskExecutor {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// When enginePaused transitions from false → true, terminate all active agent sessions.
|
||||
// Same pattern as globalPause: agents are killed, tasks moved to todo (not failed).
|
||||
store.on("settings:updated", ({ settings, previous }) => {
|
||||
if (settings.enginePaused && !previous.enginePaused) {
|
||||
for (const [taskId, session] of this.activeSessions) {
|
||||
executorLog.log(`Engine pause — terminating agent session for ${taskId}`);
|
||||
this.pausedAborted.add(taskId);
|
||||
session.dispose();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user