fix: propagate queue cancel to run state
This commit is contained in:
@@ -985,8 +985,8 @@ CREATE TABLE IF NOT EXISTS agentrun_schema_migrations (
|
||||
async cancelQueueTask(taskId: string, reason = "cancel requested"): Promise<QueueTaskRecord> {
|
||||
const task = await this.getQueueTask(taskId);
|
||||
if (isTerminalQueueTaskState(task.state)) return task;
|
||||
if (task.latestAttempt?.commandId) await this.cancelCommand(task.latestAttempt.commandId, reason);
|
||||
else if (task.latestAttempt?.runId) await this.cancelRun(task.latestAttempt.runId, reason);
|
||||
if (task.latestAttempt?.runId) await this.cancelRun(task.latestAttempt.runId, reason);
|
||||
else if (task.latestAttempt?.commandId) await this.cancelCommand(task.latestAttempt.commandId, reason);
|
||||
return this.withTransaction(async (client) => {
|
||||
const existing = await client.query("SELECT * FROM agentrun_queue_tasks WHERE id = $1 FOR UPDATE", [taskId]);
|
||||
const row = existing.rows[0];
|
||||
|
||||
+2
-2
@@ -495,8 +495,8 @@ export class MemoryAgentRunStore implements AgentRunStore {
|
||||
cancelQueueTask(taskId: string, reason = "cancel requested"): QueueTaskRecord {
|
||||
const task = this.getQueueTask(taskId);
|
||||
if (isTerminalQueueTaskState(task.state)) return task;
|
||||
if (task.latestAttempt?.commandId) this.cancelCommand(task.latestAttempt.commandId, reason);
|
||||
else if (task.latestAttempt?.runId) this.cancelRun(task.latestAttempt.runId, reason);
|
||||
if (task.latestAttempt?.runId) this.cancelRun(task.latestAttempt.runId, reason);
|
||||
else if (task.latestAttempt?.commandId) this.cancelCommand(task.latestAttempt.commandId, reason);
|
||||
const at = nowIso();
|
||||
const latestAttempt = task.latestAttempt ? { ...task.latestAttempt, state: "cancelled" as const } : null;
|
||||
const next: QueueTaskRecord = { ...task, state: "cancelled", latestAttempt, version: this.nextQueueVersion(), updatedAt: at, cancelledAt: at, cancelReason: reason };
|
||||
|
||||
Reference in New Issue
Block a user