Q7: an agent runs one session at a time

Claims skip agents that already have a running run, manual runs refuse a
busy agent, a run whose task was reassigned fails before executing, and
tasks with a run in progress cannot be deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude Opus 5.5 committed 2026-10-08 03:11:39 -04:00
1 parent 0fb4ca9ae6
commit 72eb645067
6 files changed
+129 -14

No files matched your search

+5 -2
View File
@@ -40,14 +40,17 @@ describe("task queue worker claim", () => {
const second = seedQueuedRun(connection, orgId, taskId, agentId, providerId);
const claimedA = claimNextQueuedRun(connection);
// One session per agent: the second run waits while the first is running.
expect(claimNextQueuedRun(connection)).toBeNull();
connection.db.prepare("update task_runs set state = 'completed' where id = ?").run(claimedA!.id);
const claimedB = claimNextQueuedRun(connection);
const claimedC = claimNextQueuedRun(connection);
expect([claimedA?.id, claimedB?.id].sort()).toEqual([first, second].sort());
expect(claimedC).toBeNull();
const states = (connection.db.prepare("select state from task_runs where org_id = ? order by created_at").all(orgId) as Array<{ state: string }>).map((r) => r.state);
expect(states).toEqual(["running", "running"]);
const states = (connection.db.prepare("select state from task_runs where org_id = ? order by created_at").all(orgId) as Array<{ state: string }>).map((r) => r.state).sort();
expect(states).toEqual(["completed", "running"]);
connection.close();
});