Every agent session used to be "a chat": the owner's conversations, but also
every heartbeat beat (Loop · heartbeat), every org task run (Org · Acme · Close the books), every meeting round and channel wake (#general · Jong).
They all sat in the left rail and the agent's Chats tab, and the agent's
thinking and tool calls sat inline in the conversation with its answer.
Now a session is one of two kinds. Both are in the rail and open in the same chat view; each kind also has a surface of its own:
| Kind | What it is | Where you read it |
|---|---|---|
chat |
a conversation with people | the rail (chat rows), the agent's Chats tab, chat search, the chat view |
work |
the agent's own run | the rail (each agent's Work subsection), the chat view (steps unfolded), the agent's Work log tab (the timeline) |
Requirements: chat-requirements.md FR-1.10, FR-3.2, FR-5.1, FR-8.2. The rail: chat-archiving.md. The agent page: mission-control.md.
Code:
server/src/chats/session-kind.ts— the kinds,classifySession, the owner-DM tagserver/src/chats/work-log.service.ts,work-log.controller.ts— the Work log endpointsserver/src/chats/live-turns.ts(turnWatch),chats.controller.ts(GET :id/live) — watching a turn another caller startedserver/src/chats/work-rerun.service.ts,server/src/org/org-rerun.bridge.ts— Rerunserver/src/chats/chats.repository.ts(railWhere,railCounts,approvalSessions,sessionRunMeta),chats.service.ts(rail,page,withWorkMeta,ownerChatFor),work-log.service.ts(sessionTrigger)src/components/Rails.tsx(WorkSection,workGlyph) — the rail's Work subsection;src/components/WorkLog.tsx— the tab;src/components/ChatView.tsx(WorkedOn— the folded steps in a chat;WorkSessionBar— a work session's trigger chip, Open in Work log, Rerun);src/lib/work-live.ts— the live rows of a watched run;src/store.tsx(loadMoreWork,openSession,sendToSession, the server-wait queue)- tests:
tests/backend-work-log.test.ts,tests/backend-work-log-intervene.test.ts,web-tests/work-log.test.tsx,web-tests/work-log-intervene.test.tsx,web-tests/work-log-store.test.tsx,web-tests/chat-rail.test.tsx,web-tests/chat-rail-store.test.tsx
chat_sessions.kind (migration 0080, 'chat' by default) is set when a
session is created, by the code path that creates it — every createSession
call states it, and a test fails if a new one does not:
| Created by | Kind |
|---|---|
a person: New chat, POST /api/chats |
chat |
| a fork of any session | chat |
the owner DM (ownerChatFor, below) |
chat |
a member's Telegram or email thread (Telegram · …, Email · …) |
chat |
scheduled loops and the heartbeat (Loop · <name>) |
work |
org task runs, planning, chief review, plans, ask-the-company, audits (Org · …) |
work |
channel wakes and meeting rounds — the hidden #slug · Agent session |
work |
red-team and eval runs (Red team · …, Eval · …) |
work |
mini-app asks (App · <agent>) |
work |
classifySession is the fallback for a caller that does not say, and the
rule existing rows were backfilled with: a work name prefix (Loop · ,
Org · , Red team · , Eval · , App · ), a channel working session
(#… · … or tagged channel), an org task link (taskKind = 'org'), or —
in the migration only — a session an org_runs row used. Everything else
is a chat, including a chat a turn was promoted to the kanban from. The
migration touches only rows still at the default, so a re-run never undoes
a later decision.
Delegated work (delegate_task) and code_agent runs are not sessions of
their own: the delegate runs the task from its heartbeat or its org task
run (work); a coding-agent call is a tool call inside whichever session made
it.
The kind is presentation, not behaviour. The turn loop, the turn context, memory, distillation and compaction read the same sessions the same way; no model input depends on the kind, and the turn context never keys on session names. A work session's turns still run with the session's own permission mode, model and token ceiling.
ChatsService.ownerChatFor(agentId) is the conversation an agent's messages
to its owner land in (message_owner): the agent's newest live chat tagged
owner-dm, the owner's own (initiatedBy '', not shared), created on first
use and replaced if archived. Always chat, so what an agent says to its
owner is a chat row in the rail, never a work session.
- The rail lists both kinds under each agent: its chats first (pinned,
then newest), then a Work subsection with its work sessions — the same
session rows (title, time, the approval dot) with a small trigger glyph
(loop, the task key, channel, org, app) and a pulsing green dot
while a run is going. A row reads by what its glyph does not say: the
heartbeat as Heartbeat, a loop by its name, a task run by its task's
title, a channel session by its
#slug, an org run withoutOrg ·. Newest activity first; the heartbeat and each loop run in one session each, so they are one row however many beats ran. The subsection is folded by default, and open by itself while one of its sessions is running, waits on an approval, or is the open session; folding it by hand is kept per viewer (localStorageyaam-rail-work). Its header shows the count, the running and approval dots, and a clock button to the agent's Work log tab. Show more (N) pages it like chats. The archive counts chats only. - The API.
GET /api/chats/railreturns per groupwork: { total, items, nextCursor, approvalIds }— the firstperAgent(5) work sessions, or as many asworkLimits=<agentId>:<n>,…asks for, so a refresh keeps what Show more loaded.GET /api/chats/page?kind=work&agentId=…&cursor=pages them. Every work session the rail, the page andGET/PATCH /api/chats/:idreturn carriestrigger,triggerKey,triggerLabel(sessionTrigger: the session-level trigger — a channel session readschannel, meeting rounds in it are told apart per run in the Work log) andrunning(its newest turn is running). The rail re-reads itself each minute so the work rows follow the runs. - Approvals. A run waiting on an approval (an
action_pending/approval_requestinbox event on a work session) is an Inbox item as before, a red badge on the agent's rail group (it opens the group and its Work subsection), a dot on its row and the subsection header, and a count on the Work log tab. - The agent's Chats tab lists and counts its chats.
- Search. The rail search (
/api/chats/rail?q=) covers both kinds — name, auto-title, tags — and opens the groups and Work subsections with hits; All / Chats / Work under the box narrows it (kind=chat|work). Message search (/api/search) covers chat sessions; the Work log has its own search over runs. - Links.
openSession(id)opens the chat view for both kinds. That covers the rail, the Inbox, mission control and the agent dashboard (See the run, the error's run), Settings › Usage, the org run list and#/chat/<id>deep links from notifications (#/chat/<id>/chatis an alias).#/chat/<id>/logopens a work session's timeline in the agent's Work log instead, its newest run expanded;openWorkLogdoes the same from code.
Everything a chat has works the same — streaming, the composer and its
queue, Stop, inline approvals, Ask/Auto, the model menu. A strip under the
header shows a trigger chip (Heartbeat, Loop · digest, ENG-12 Close
the books, #general), Open in Work log (the agent's Work log filtered
to this session), and Rerun when the session's last run errored or was
stopped (the Work log's rerun endpoint below: the same trigger again, in
this session). A person's message is a turn with origin user; the session
stays work.
In a conversation each turn's thinking and tool calls fold behind one line, worked on it · N steps, placed where the first of them was; the answer stays in view. The owner can expand it. While a turn runs the line reads working · N steps…, and a tool call waiting on the owner's approval stays in view outside the fold. A work session in the chat view shows its thinking and tool calls unfolded, as the Work log does.
Thinking is now kept: each round's thinking is a thinking transcript row
(bounded at 50k characters). Provider history never carries it
(providerHistory reads user and assistant rows), export skips it, and chat
search ignores it.
The agent page's Work log tab (?tab=Work log, also worklog, runs,
Heartbeat runs; linked from the Overview's Activity, the mission-control
side panel and the rail). One run is one turn of a work session.
The timeline. Runs newest first, by day. A row: the outcome dot, the time, the trigger label, the answer's first line (or the error), steps, tokens and cost, the outcome.
Grouped by trigger. Chips across the top, one per trigger group with its count, newest group first — Heartbeat, Loop · digest, ENG-12 Close the books, Meeting · #eng, #general, the org sessions (Acme · Planning · Eng), Mini app · Jong. A chip filters to that group; All clears it.
| Trigger | Run of | Key |
|---|---|---|
heartbeat |
Loop · heartbeat |
— |
loop |
Loop · <name> |
the loop name |
task |
a session linked to a task (org run or kanban) | the task key (else id) |
meeting |
the channel session, a turn opened by a meeting round prompt | #slug |
channel |
the channel session, any other turn (a wake) | #slug |
org |
other Org · …, red-team and eval sessions |
the session name |
app |
App · … |
the session name |
Outcome. running; interrupted (a server restart cut it short — see
below); error (the turn errored, or its org run failed, looped or was
killed); blocked (its org run ended blocked, a budget stop, or was
refused); stopped; else done. A task run's outcome and cost come
from the org_runs row that ran it (the latest started before the turn).
A run a server restart cut short is interrupted, not an error
(architecture.md): a grey dot, no
red text, and it never counts as a failing agent, a loop error, a breaker or
a Run failed in the Inbox. The row reads what the boot after did with it
(recovery on the run, resumedBy the run that resumed it):
- Interrupted by a restart · resumed — a heartbeat, loop or task run, re-run once by its trigger; the detail links the resumed run, which reads rerun;
- Interrupted by a restart · retry — a person's chat (never re-sent on its own: the chat shows the same line with Retry), or a run left to its own schedule; Rerun applies;
- Interrupted by a restart mid-action · check it — it stopped inside an outward call whose outcome nobody knows, so it was not replayed: the owner is told, an org task is blocked on the CEO until someone checks.
Cost. The org run's settled USD when there is one, else the model's list price for the turn's tokens (Settings › Usage overrides apply); blank for a model the table does not know.
A run, expanded: the prompt (folded), each thinking block, each tool call
with its input and its output (and ERROR / a non-default approval), the
answers, the files it wrote (fs_write, fs_edit, fs_append,
fs_delete, fs_restore — each opens in Artifacts), tokens in and out, the
model, cost, and a link to its task (an org task's drawer, or the agent's
board).
Filters: trigger (and key), outcome, task (key or id, any case), from /
to (whole days), and search — the prompt, the session name, the task key
and title, and every message of the run, thinking included (LIKE
wildcards are literal). Paging: 30 runs a page, Load more runs
(opaque cursor on createdAt, id).
Archived sessions. Auto-archive sweeps finished task sessions — mostly work sessions (chat-archiving.md). Their runs stay in the Work log, marked archived session: the log is history.
GET /api/agents/:agentId/work-log?trigger=&key=&outcome=&task=&session=&from=&to=&q=&limit=&cursor=
→ { runs: WorkRun[], nextCursor, groups: [{ trigger, key, label, count, lastAt }] }
GET /api/agents/:agentId/work-log/runs/:turnId
→ WorkRun + { messages (in order, thinking included), toolCalls (input, result, approved, isError) }
GET /api/agents/:agentId/work-log/sessions/:sessionId/latest
→ { turnId }
POST /api/agents/:agentId/work-log/runs/:turnId/rerun
→ { started, turnId, sessionId, status, error? }
GET /api/chats/:id/live (SSE)
→ { type: 'live', turnId, source, startedAt }, the turn's events so far,
each new one, { type: 'end' } — or { type: 'idle', busy } when no turn runs
A run also carries source (who sent it: person, else its origin loop,
user, channel, app; '' for turns from before migration 0081), by
(the person behind a person run, '' = the owner), rerunOf and
rerunnable (failed, stopped or blocked).
The list reads work sessions only; a run by id opens for any session of the agent, so a link never breaks on the kind. A member of a shared workspace sees the runs of shared sessions and their own, as with chats. The groups are counted under every filter but the trigger, so the chips stay put while filtering.
The owner — and a member, on the sessions they can open — can step into a work session from the Work log. Viewers read the same views and nothing else.
Live. A run in progress opens by itself and streams: its thinking, each
tool call with its result, its answers, under running · step N with a
pulsing dot (the row shows the same line). The Work log watches the turn
through GET /api/chats/:id/live: the turn loop publishes every event of
every turn into an in-process registry (turnWatch, beside liveTurns) as it
yields it, so a watcher that did not start the turn — a heartbeat, a task run,
a meeting round — gets the replay so far (token deltas merged, a pending
approval kept) and then each event, then end. The registry is in-process
and best-effort: on a multi-instance deployment the instance a watcher
reaches may not run the turn; it answers idle with busy, and the Work log
falls back to re-reading the run every 2 s (persisted rows: thinking, tool
results, answers as each round ends). While anything is running or a message
waits, the log re-reads its first page every 3 s, keeping what Load more
fetched.
Stop and approvals. Stop is POST /api/chats/:id/stop; a tool call
waiting for approval shows inline with the same card and review details as in
a chat (Allow once, Allow always, Always allow , Deny), answered
through POST /api/chats/:id/approve. Both now check the caller may open the
session (a member: shared sessions and their own), as the turn route did.
Message the agent in this work session. A composer under an expanded run
and under a session's run list (the session filter). Idle, it starts a turn in
that session through POST /api/chats/:id/turns — origin user, so the
session's Ask/Auto mode and the normal approval policy apply, and the
session stays work. While a turn runs it queues for the next turn of that
session (the chat's per-session queue): behind a turn this tab started it
goes when that turn ends; behind a turn the server started (waitServer) the
store watches the session and sends it when that turn is over (a 409 chat is busy from a race requeues it the same way). Queued messages show under the
composer and can be removed. There is no mid-turn injection: the turn loop
has no safe point to add a user message between rounds across providers, so
a steer lands on the next turn. A person's turn is stored with
source = 'person' (migration 0081) and reads in the timeline as from you
/ from , the message shown as theirs rather than as a folded prompt.
Continue in chat. Opens the same session in the chat view — the full
transcript and composer, as from its rail row — while it stays work (in
the rail's Work subsection, out of the Chats tab). The view's strip has its
trigger chip and Open in Work log (§2).
Deep link: #/chat/<id> (or #/chat/<id>/chat); #/chat/<id>/log opens
the Work log.
Rerun. A failed, stopped, blocked or interrupted run — failed for a reason fixed since (a provider 400, an outage, a budget or tool-round limit raised), or cut short by a restart — has Rerun: the same trigger again, in the same work session.
| Trigger | Rerun |
|---|---|
| heartbeat | the heartbeat beats now (beat(force): quiet hours, the spend stop and the daily cap still apply; no reasons → nothing runs) |
| loop | the loop fires now (runLoop: its own prompt, model and budget); a loop since removed is an error |
| task (org) | the org runtime re-dispatches the task (runTask(…, 'manual'): seat, claim, capacity, budget reservation, the task's own wake prompt) |
| meeting, channel, org, app, other, a person's message | the run's input (and attachments) again, with its origin (loop, user, channel, or a confined app ask) |
The new turn carries rerunOf (the row reads rerun, the run links rerun of
an earlier run). One rerun at a time per session, and a session mid-turn is
refused (409). The request waits up to 8 s for the new turn to start and
returns its id; a gate that refuses says why (status: cap, quiet,
skipped:closed, …). The agent page's error cause offers See the run ·
Rerun when the failing run is the newest of its work session and failed or
stopped (cause.rerunTurnId).