Skip to content

Database tables for sessions and turns

This page lists the columns of sessions, events, raw_events, turns, helper_passes and session_reads. Database tables says how to read the columns.

One run of a harness, Claude or Codex, for a task or a conversation. The session id is the key, and harness_session_id is the harness’s id, used to resume.

Column Type Notes
id uuid key
team_id uuid references teams
task_id uuid optional; references tasks
conversation_id uuid optional; references conversations
workspace_id uuid optional; references workspaces
instance_id uuid references instances
agent_id uuid optional; references agents
stage text optional
started_by uuid optional; references people
started_by_session uuid optional; references sessions
harness text default 'claude'
harness_session_id text optional
model text optional
status text default 'starting'; one of draft, starting, running, idle, needs_input, needs_approval, limited, lost, failed
limited_until timestamptz optional; when the plan’s usage limit resets, set exactly while status is limited
limited_account text optional; the Claude account the session met the limit on, set only while status is limited
last_seq bigint default 0
cost_usd numeric(12,4) optional
turns integer default 0
last_active_at timestamptz optional
archived_at timestamptz optional
created_at timestamptz default now()
folder_id uuid optional; references connected_folders
cwd text optional
seat_id uuid optional; references seats

Unique (instance_id, harness_session_id) where (folder_id IS NOT NULL). Check CASE WHEN (folder_id IS NULL) THEN ((agent_id IS NOT NULL) AND (cwd IS NULL) AND ((task_id IS NULL) <> (conversation_id IS NULL))) ELSE ((agent_id IS NULL) AND (task_id IS NULL) AND (conversation_id IS NULL) AND (workspace_id IS NULL) AND (cwd IS NOT NULL) AND (harness_session_id IS NOT NULL)) END.

One entry in a session’s record. Events are only added, with two exceptions. A leaked secret is redacted, and deleting a chat post clears the post’s own event and the post’s words where other events quote them. Each is kept whole.

Anthropic returns a summary of a model’s reasoning, never the raw text, so a thinking event holds that summary. Claude 5.x models hide it unless asked, which needs Claude Code 2.1.94 or later, and a newer one for a helper’s (2.1.296 can, 2.1.148 cannot). On an older one the session runs as before, and a 5.x model’s event has empty text.

Column Type Notes
id bigint key; default nextval('events_id_seq')
team_id uuid references teams
session_id uuid references sessions
seq bigint
updated_seq bigint
kind text one of user, assistant, thinking, tool_call, tool_result, ask, answer, notice, error, usage
author uuid optional; references people
parent_tool_use_id text optional
tool_use_id text optional
tool_name text optional
text text optional
body jsonb
client_id text
created_at timestamptz default now()
author_agent uuid optional; references agents

Unique (session_id, client_id). Unique (session_id, seq). Check ((author_agent IS NULL) OR ((author IS NULL) AND (kind = 'user'))).

Claude’s raw output lines, keyed by Claude’s own line id so a resumed session never collides.

Column Type Notes
id bigint key; default nextval('raw_events_id_seq')
session_id uuid references sessions
client_id text
line jsonb
created_at timestamptz default now()

Unique (session_id, client_id).

A request for an agent to work, and what became of it. source says what asked for it. A turn waits for its machine, runs, and ends.

Column Type Notes
id uuid key
team_id uuid references teams
conversation_id uuid optional; references conversations
agent_id uuid references agents
requested_at timestamptz default now()
deadline timestamptz optional
winding_down boolean default false
outcome text optional; one of sent, pass, skipped, timeout, cancelled, error
finished_at timestamptz optional
started_at timestamptz optional
source text default 'room'; one of agent, delegation, person, pipeline, room, routine
task_id uuid optional; references tasks
run_id uuid optional; references runs
routine_id uuid optional; references routines
asked_by_person uuid optional; references people
session_id uuid optional; references sessions
event_id bigint optional; references events
payload jsonb optional
status text default 'queued'; one of queued, waiting, placed, running, done, failed, cancelled
wait text optional; one of computer_starting, machine_offline, seat, usage_limit
wait_until timestamptz optional; when a usage_limit wait ends, set exactly for one
instance_id uuid optional; references instances
command_id uuid optional; references commands
placed_at timestamptz optional
stuck_since timestamptz optional
asked_by_session uuid optional; references sessions
answer_to_turn uuid optional; references turns
answer_sent_at timestamptz optional
hops integer default 0
sent_by_turn uuid optional; references turns
answer_error text optional
origin_conversation_id uuid optional; references conversations

Check ((routine_id IS NULL) OR (source = 'routine')). Check ((source = 'room') = (deadline IS NOT NULL)). Check ((source = ANY (ARRAY['agent', 'delegation'])) = (hops > 0)). Check ((status = 'waiting') = (wait IS NOT NULL)). Check CHECK (((status = ANY (ARRAY['queued', 'cancelled'])) OR ((session_id IS NOT NULL) AND (event_id IS NOT NULL) AND (payload IS NOT NULL)))) NOT VALID. Check (num_nonnulls(conversation_id, task_id, run_id) = 1).

A finished turn that started a helper, a background agent Claude runs on after the turn’s result. While its pass is open, the agent tools answer in its session, and the helper’s messages count toward its turn’s limit of 5 in sends. A stop or interrupt for the session ends it at once. Its row closes when the Claude process that started the helper exits, when the machine starts again, or after 35 minutes with nothing posted from the session. While the helper waits on a person’s approval, that close comes no sooner than 24 hours after the ask.

Column Type Notes
turn_id uuid key; references turns
session_id uuid references sessions
process_id uuid the Claude process that started the helper
opened_at timestamptz default now()
closed_at timestamptz optional; null while open
sends integer default 0; messages the helper sent from this pass

How far each session has been read for evidence, so each event is read once.

Column Type Notes
session_id uuid key; references sessions
team_id uuid references teams
read_to_seq bigint
run_id uuid optional; references runs
read_at timestamptz default now()