mirror of
https://github.com/n8n-io/n8n.git
synced 2026-10-17 13:39:44 +02:00
A message sent while the thread runs a turn becomes an `agent_execution` row with status `queued`. The row is visible in every tab, survives a reload, and runs after the current turn ends. - Migration adds the `queued` status and an `agent_execution.resourceId` column that records the sender of a queued turn. - `AgentChatQueueService` stores, edits, removes, and drains queued rows. Draining runs oldest-first through `executeForQueued`, before any background wake; the sweeper drains as a fallback. - New routes: `POST /chat/queue`, `PATCH /chat/queue/:executionId`, `DELETE /chat/queue/:executionId`. - The transcript carries `executionStatus: 'queued'`; the sessions list and the LangSmith export ignore queued rows. - The composer stays live while a turn runs: it enqueues instead of waiting. Queued bubbles show inline edit and remove actions. Co-authored-by: Cursor <cursoragent@cursor.com>
5.0 KiB
Generated
5.0 KiB
Generated
agent_execution
Description
Table Definition
CREATE TABLE "agent_execution" ("id" varchar(36) PRIMARY KEY NOT NULL, "threadId" varchar(128) NOT NULL, "status" varchar(16) NOT NULL, "startedAt" datetime(3), "stoppedAt" datetime(3), "duration" integer NOT NULL DEFAULT (0), "userMessage" text, "model" varchar(255), "promptTokens" integer, "completionTokens" integer, "totalTokens" integer, "cost" real, "timeline" text, "error" text, "hitlStatus" varchar(16), "source" varchar(32), "createdAt" datetime(3) NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')), "updatedAt" datetime(3) NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW')), "storedAt" varchar(2) NOT NULL DEFAULT ('db'), "attachments" text, "failureSummary" text, "author" text, "activeThreadId" varchar(128), "resourceId" varchar(255), CONSTRAINT "CHK_agent_execution_storedAt" CHECK (((("storedAt" IN ('db', 'fs', 's3', 'az'))))), CONSTRAINT "CHK_agent_execution_hitlStatus" CHECK ((((((("hitlStatus" IN ('suspended', 'resumed')))))))), CONSTRAINT "CHK_agent_execution_status" CHECK ("status" IN ('queued', 'running', 'success', 'error', 'cancelled', 'interrupted')), CONSTRAINT "FK_add2432fb6034cc18b6af299dce" FOREIGN KEY ("threadId") REFERENCES "agent_execution_threads" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)
Columns
| Name | Type | Default | Nullable | Children | Parents | Comment |
|---|---|---|---|---|---|---|
| activeThreadId | varchar(128) | true | ||||
| attachments | TEXT | true | ||||
| author | TEXT | true | ||||
| completionTokens | INTEGER | true | ||||
| cost | REAL | true | ||||
| createdAt | datetime(3) | STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW') | false | |||
| duration | INTEGER | 0 | false | |||
| error | TEXT | true | ||||
| failureSummary | TEXT | true | ||||
| hitlStatus | varchar(16) | true | ||||
| id | varchar(36) | false | ||||
| model | varchar(255) | true | ||||
| promptTokens | INTEGER | true | ||||
| resourceId | varchar(255) | true | ||||
| source | varchar(32) | true | ||||
| startedAt | datetime(3) | true | ||||
| status | varchar(16) | false | ||||
| stoppedAt | datetime(3) | true | ||||
| storedAt | varchar(2) | 'db' | false | |||
| threadId | varchar(128) | false | agent_execution_threads | |||
| timeline | TEXT | true | ||||
| totalTokens | INTEGER | true | ||||
| updatedAt | datetime(3) | STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW') | false | |||
| userMessage | TEXT | true |
Constraints
| Name | Type | Definition |
|---|---|---|
| - | CHECK | CHECK (((("storedAt" IN ('db', 'fs', 's3', 'az'))))) |
| - | CHECK | CHECK ((((((("hitlStatus" IN ('suspended', 'resumed')))))))) |
| - | CHECK | CHECK ("status" IN ('queued', 'running', 'success', 'error', 'cancelled', 'interrupted')) |
| - (Foreign key ID: 0) | FOREIGN KEY | FOREIGN KEY (threadId) REFERENCES agent_execution_threads (id) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE |
| id | PRIMARY KEY | PRIMARY KEY (id) |
| sqlite_autoindex_agent_execution_1 | PRIMARY KEY | PRIMARY KEY (id) |
Indexes
| Name | Definition |
|---|---|
| IDX_63d3c3a68b9cebf05f967f0b1c | CREATE INDEX "IDX_63d3c3a68b9cebf05f967f0b1c" ON "agent_execution" ("threadId", "createdAt") |
| IDX_agent_execution_activeThreadId | CREATE UNIQUE INDEX "IDX_agent_execution_activeThreadId" ON "agent_execution" ("activeThreadId") WHERE "activeThreadId" IS NOT NULL AND "status" = 'running' |
| IDX_agent_execution_status | CREATE INDEX "IDX_agent_execution_status" ON "agent_execution" ("status") WHERE "status" = 'running' |
| sqlite_autoindex_agent_execution_1 | PRIMARY KEY (id) |
Relations
erDiagram
"agent_execution" }o--|| "agent_execution_threads" : "FOREIGN KEY (threadId) REFERENCES agent_execution_threads (id) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE"
"agent_execution" {
varchar_128_ activeThreadId
TEXT attachments
TEXT author
INTEGER completionTokens
REAL cost
datetime_3_ createdAt
INTEGER duration
TEXT error
TEXT failureSummary
varchar_16_ hitlStatus
varchar_36_ id PK
varchar_255_ model
INTEGER promptTokens
varchar_255_ resourceId
varchar_32_ source
datetime_3_ startedAt
varchar_16_ status
datetime_3_ stoppedAt
varchar_2_ storedAt
varchar_128_ threadId FK
TEXT timeline
INTEGER totalTokens
datetime_3_ updatedAt
TEXT userMessage
}
"agent_execution_threads" {
varchar_36_ agentId FK
varchar_255_ agentName
datetime_3_ createdAt
varchar_8_ emoji
varchar_128_ id PK
varchar_36_ parentAgentId
varchar_128_ parentThreadId
varchar_255_ projectId FK
INTEGER sessionNumber
varchar_32_ taskId
varchar_36_ taskVersionId FK
varchar_255_ title
INTEGER totalCompletionTokens
REAL totalCost
INTEGER totalDuration
INTEGER totalPromptTokens
datetime_3_ updatedAt
}
Generated by tbls