Skip to main content

Module session

Module session 

Source
Expand description

Saved Agent conversations: one append-only JSON Lines file per review session, which session show reads and session send continues.

$STATE/agent-sessions/ (owner-only) holds <sessionId>.jsonl, an owner-only file of one JSON event per line, and <sessionId>.lock, which serializes the sends to it:

  • review, first: the session, Run, request and eval ids, the producer and state id, the backend, model, reasoning, provider parameters, budgets and tool definitions;
  • message: one rig Message exactly as the provider received or sent it, with the turn (the provider request) that carried it. The system prompt and instructions come first, then each answer with its reasoning (encrypted reasoning items and thinking signatures included), tool calls and their results. A message of tool results has isError, whether each result failed, in order. The repair prompt has repair, and the answer it replaced is the message before it;
  • attempt: one provider attempt of a turn, its usage counters and any error;
  • end: the review’s result, or its errorCode and error;
  • send and answer around each follow-up, whose events carry its send number.

Every event has its time in at. Writing never fails a review: an error is reported on stderr and the review goes on without its conversation.

Modules§

document
Pure session layout and scrolling, shared by terminal and future graphical viewers. Rows are indexed by logical UTF-8 offsets, not terminal-sized global scroll coordinates.
live
Incremental, state-scoped session reading. Call bounded step jobs off the UI thread. Only byte offsets and row counts survive cache eviction; older history is paged in on demand.
transcript
Semantic, minimal session presentation. Stored events remain lossless; this view keeps only prose and bounded activity headers, never tool output, arguments, reasoning or media payloads.

Structs§

Budgets
Collection
What one collection found and did.
Conversation
A saved conversation, read whole.
Delivery
Event
Header
MessageEvent
Recorder
Appends one session’s events. It writes nothing when saving is off, and after a failed write it reports the error once and writes nothing more.
Saving
Where new conversations are saved, and as which producer and state; None when saving is off (agentSessions.enabled: false in limits.json).
Send
SessionRef
Where an Agent review’s conversation lives: the producing user@host, the state (by its stable id), and the Run, request and session ids. Its text form is user@host/<state>/<runId>/<requestId>/<sessionId>.
Summary
A saved conversation’s backend, time span, turns, tokens and tool calls.
Usage
The session store’s size.

Enums§

Answer
DeliveryKind
DeliveryState
End
Kind

Constants§

DIRECTORY
The session store below the state directory.

Functions§

collect
Collect the store under bounds (see the module). The sessions that are listed first and then found RUNNING were saved after their request turned RUNNING, so a review that starts during a collection is either seen as running or not listed at all.
directory
The session store of a state.
lock
Hold <sessionId>.lock until the returned file drops: sends to one session take turns.
path
The conversation file of a session id.
tokens_text
Token counters as text, in a fixed order with readable names; None without any.
usage
How many conversations the store holds and their bytes.