Database tables for conversations
This page lists the columns of conversations, conversation_members, messages, message_versions, pins, reactions and attachments. Database tables says how to read the columns.
conversations
Section titled “conversations”A place where people and agents talk. last_seq is the number of its last message. Only a room has a project_id. Only a pr conversation, the chat of a task’s pull request, has an artifact_id, and who reads that chat is read from the artifact’s task, not from visibility.
| Column | Type | Notes |
|---|---|---|
id |
uuid |
key |
team_id |
uuid |
references teams |
kind |
text |
one of agents, dm, main, pr, room, slack_thread |
name |
text |
optional |
avatar |
jsonb |
optional |
agent_id |
uuid |
optional; references agents |
source |
text |
optional |
visibility |
text |
default 'team'; one of team, private |
last_seq |
bigint |
default 0 |
archived_at |
timestamptz |
optional |
created_at |
timestamptz |
default now() |
project_id |
uuid |
optional; references projects |
artifact_id |
uuid |
optional; unique; references artifacts |
Check ((kind <> ALL (ARRAY['main', 'dm'])) OR (agent_id IS NOT NULL)). Check ((project_id IS NULL) OR (kind = 'room')). Check ((artifact_id IS NULL) OR (kind = 'pr')).
conversation_members
Section titled “conversation_members”A person or an agent in a conversation, with how far the person has read.
| Column | Type | Notes |
|---|---|---|
id |
bigint |
key; default nextval('conversation_members_id_seq') |
team_id |
uuid |
references teams |
conversation_id |
uuid |
references conversations |
person_id |
uuid |
optional; references people |
agent_id |
uuid |
optional; references agents |
last_read_seq |
bigint |
default 0 |
joined_at |
timestamptz |
default now() |
Unique (conversation_id, person_id) where (person_id IS NOT NULL). Unique (conversation_id, agent_id) where (agent_id IS NOT NULL). Check ((person_id IS NULL) <> (agent_id IS NULL)).
messages
Section titled “messages”A post in a conversation. seq numbers the posts of a conversation. A deleted post keeps its row with deleted_at set.
| Column | Type | Notes |
|---|---|---|
id |
uuid |
key |
team_id |
uuid |
references teams |
conversation_id |
uuid |
references conversations |
seq |
bigint |
|
speaker |
text |
one of person, agent |
person_id |
uuid |
optional; references people |
agent_id |
uuid |
optional; references agents |
body |
text |
|
quoted_message_id |
uuid |
optional; references messages |
session_id |
uuid |
optional; references sessions |
event_id |
bigint |
optional; references events |
task_id |
uuid |
optional; references tasks |
client_id |
text |
|
edited_at |
timestamptz |
optional |
deleted_at |
timestamptz |
optional |
created_at |
timestamptz |
default now() |
kind |
text |
default 'post'; one of post, answer, chain_stopped |
asked_agent_id |
uuid |
optional; references agents |
deleted_by |
uuid |
optional; references people |
Unique (conversation_id, client_id). Unique (conversation_id, seq). Check ((asked_agent_id IS NULL) OR (kind = 'answer')). Check ((deleted_at IS NULL) OR (body = '')).
message_versions
Section titled “message_versions”The earlier text of a message that was edited.
| Column | Type | Notes |
|---|---|---|
id |
bigint |
key; default nextval('message_versions_id_seq') |
message_id |
uuid |
references messages |
body |
text |
|
edited_by |
uuid |
optional; references people |
replaced_at |
timestamptz |
default now() |
A message pinned in a conversation.
| Column | Type | Notes |
|---|---|---|
conversation_id |
uuid |
references conversations |
message_id |
uuid |
references messages |
team_id |
uuid |
references teams |
pinned_by |
uuid |
optional; references people |
created_at |
timestamptz |
default now() |
Primary key (conversation_id, message_id).
reactions
Section titled “reactions”One emoji by one person or agent on a message or on an event of a session.
| Column | Type | Notes |
|---|---|---|
id |
uuid |
key |
team_id |
uuid |
references teams |
conversation_id |
uuid |
optional; references conversations |
session_id |
uuid |
optional; references sessions |
message_id |
uuid |
optional; references messages |
event_id |
bigint |
optional; references events |
emoji |
text |
|
person_id |
uuid |
optional; references people |
agent_id |
uuid |
optional; references agents |
created_at |
timestamptz |
default now() |
told_agent_at |
timestamptz |
optional |
Unique (message_id, emoji, person_id) where ((message_id IS NOT NULL) AND (person_id IS NOT NULL)). Unique (message_id, emoji, agent_id) where ((message_id IS NOT NULL) AND (agent_id IS NOT NULL)). Unique (event_id, emoji, person_id) where ((event_id IS NOT NULL) AND (person_id IS NOT NULL)). Unique (event_id, emoji, agent_id) where ((event_id IS NOT NULL) AND (agent_id IS NOT NULL)). Check ((event_id IS NULL) OR ((session_id IS NOT NULL) AND (conversation_id IS NULL))). Check ((message_id IS NOT NULL) <> (event_id IS NOT NULL)). Check ((message_id IS NULL) OR ((conversation_id IS NOT NULL) AND (session_id IS NULL))). Check ((octet_length(emoji) >= 1) AND (octet_length(emoji) <= 32)). Check ((person_id IS NOT NULL) <> (agent_id IS NOT NULL)).
attachments
Section titled “attachments”A file in a chat or a task’s session. The bytes live outside Postgres, in AGENTS_ATTACHMENTS_DIR, one file for each row named by the row’s id.
| Column | Type | Notes |
|---|---|---|
id |
uuid |
key |
team_id |
uuid |
references teams |
conversation_id |
uuid |
optional; references conversations |
session_id |
uuid |
optional; references sessions |
message_id |
uuid |
optional; references messages |
event_id |
bigint |
optional; references events |
kind |
text |
one of image, file |
name |
text |
|
media_type |
text |
|
size |
bigint |
|
width |
integer |
optional |
height |
integer |
optional |
added_by_person |
uuid |
optional; references people |
added_by_agent |
uuid |
optional; references agents |
created_at |
timestamptz |
default now() |
Check ((conversation_id IS NULL) OR (session_id IS NULL)). Check ((event_id IS NULL) OR (session_id IS NOT NULL)). Check ((message_id IS NULL) OR (conversation_id IS NOT NULL)). Check ((message_id IS NULL) OR (event_id IS NULL)). Check ((size >= 1) AND (size <= 26214400)). Check ((width IS NULL) = (height IS NULL)).