# agent_execution

## Description

<details>
<summary><strong>Table Definition</strong></summary>

```sql
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 NOT NULL, "assistantResponse" text NOT NULL, "model" varchar(255), "promptTokens" integer, "completionTokens" integer, "totalTokens" integer, "cost" real, "toolCalls" text, "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')), CONSTRAINT "CHK_agent_execution_status" CHECK (("status" IN ('success', 'error'))), CONSTRAINT "CHK_agent_execution_hitlStatus" CHECK (("hitlStatus" IN ('suspended', 'resumed'))), CONSTRAINT "FK_add2432fb6034cc18b6af299dce" FOREIGN KEY ("threadId") REFERENCES "agent_execution_threads" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)
```

</details>

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| id | varchar(36) |  | false |  |  |  |
| threadId | varchar(128) |  | false |  | [agent_execution_threads](agent_execution_threads.md) |  |
| status | varchar(16) |  | false |  |  |  |
| startedAt | datetime(3) |  | true |  |  |  |
| stoppedAt | datetime(3) |  | true |  |  |  |
| duration | INTEGER | 0 | false |  |  |  |
| userMessage | TEXT |  | false |  |  |  |
| assistantResponse | TEXT |  | false |  |  |  |
| model | varchar(255) |  | true |  |  |  |
| promptTokens | INTEGER |  | true |  |  |  |
| completionTokens | INTEGER |  | true |  |  |  |
| totalTokens | INTEGER |  | true |  |  |  |
| cost | REAL |  | true |  |  |  |
| toolCalls | TEXT |  | true |  |  |  |
| timeline | TEXT |  | true |  |  |  |
| error | TEXT |  | true |  |  |  |
| hitlStatus | varchar(16) |  | true |  |  |  |
| source | varchar(32) |  | true |  |  |  |
| createdAt | datetime(3) | STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW') | false |  |  |  |
| updatedAt | datetime(3) | STRFTIME('%Y-%m-%d %H:%M:%f', 'NOW') | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| id | PRIMARY KEY | PRIMARY KEY (id) |
| - (Foreign key ID: 0) | FOREIGN KEY | FOREIGN KEY (threadId) REFERENCES agent_execution_threads (id) ON UPDATE NO ACTION ON DELETE CASCADE MATCH NONE |
| sqlite_autoindex_agent_execution_1 | PRIMARY KEY | PRIMARY KEY (id) |
| - | CHECK | CHECK (("status" IN ('success', 'error'))) |
| - | CHECK | CHECK (("hitlStatus" IN ('suspended', 'resumed'))) |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_63d3c3a68b9cebf05f967f0b1c | CREATE INDEX "IDX_63d3c3a68b9cebf05f967f0b1c" ON "agent_execution" ("threadId", "createdAt")  |
| sqlite_autoindex_agent_execution_1 | PRIMARY KEY (id) |

## Relations

```mermaid
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_36_ id PK
  varchar_128_ threadId FK
  varchar_16_ status
  datetime_3_ startedAt
  datetime_3_ stoppedAt
  INTEGER duration
  TEXT userMessage
  TEXT assistantResponse
  varchar_255_ model
  INTEGER promptTokens
  INTEGER completionTokens
  INTEGER totalTokens
  REAL cost
  TEXT toolCalls
  TEXT timeline
  TEXT error
  varchar_16_ hitlStatus
  varchar_32_ source
  datetime_3_ createdAt
  datetime_3_ updatedAt
}
"agent_execution_threads" {
  varchar_128_ id PK
  varchar_36_ agentId FK
  varchar_255_ agentName
  varchar_255_ projectId FK
  INTEGER sessionNumber
  INTEGER totalPromptTokens
  INTEGER totalCompletionTokens
  REAL totalCost
  INTEGER totalDuration
  varchar_255_ title
  varchar_8_ emoji
  datetime_3_ createdAt
  datetime_3_ updatedAt
  varchar_32_ taskId
  varchar_36_ taskVersionId FK
  varchar_128_ parentThreadId
  varchar_36_ parentAgentId
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)
