A local-first multi-agent app development platform, built on PenguinHarness
title: Sessions & Traces description: The six-level run model, the data layout on disk, how the append-only Trace is written, and how a Session is recovered from it.
All Adelie runtime data lives on the local file system. Configuration is editable files, and history is an append-only Trace. This page defines each level of the run model and the layout on disk, then explains how the Trace serves as history, recovery source and statistics source at once.
Run model
The run model has six levels: Project → Agent → Workspace → Session → Task → Request.
| Concept | Definition |
|---|---|
| Project | Top-level unit that organizes agents; owns the model and credential configuration; in a multi-user Web deployment, users and Projects are many-to-many |
| Agent | The executing subject; has exactly one Agent State (a persistent directory); one agent can serve many Workspaces |
| Workspace | The working directory of one run — the only file scope the model sees; an explicit workspaceDir must already exist; when none is given, a temporary Workspace workspaces/tmp-<8hex> is created |
| Session | A continuous conversation under one (Agent, Workspace); the Workspace is locked at Session creation, and the model chosen then can be switched inside the Session (see In-session model switch); ids look like session-YYYY-MM-DD-HH-mm-ss-<8hex> |
| Task | One execution goal started by one Prompt; consists of one or more consecutive Requests |
| Request | One LLM API call: context and tool definitions in, streamed output out |
For how the levels work together, see Architecture. For how Requests advance within a Task, see The Agent Loop.
Data layout
The data root is the ADELIE_HOME environment variable, ~/.adelie/data by default. The layout is defined in one place, packages/core/src/state/paths.ts:
<root>/<project>/
├── .project_config.toml # Project-level models & credentials (hidden file, 0600)
├── benchmarks/ # capability Benchmark cases and scores, one directory per
│ # Benchmark — a peer of the Agents, evaluating any of them
└── agents/
└── <agent>/
├── agent_state/ # system_config.yaml, AGENTS.md, .vault.toml,
│ # tools/, skills/, hooks/, schedule/
│ └── memory/ # Memory: user/ plus one directory per Workspace,
│ # each with its own MEMORY.md index
├── traces/
│ └── <yyyy-mm-dd>/<sessionId>_<index3>.jsonl
├── scratchpad/ # temp files, one subdirectory per Session id (e.g. pasted images)
├── shared_env/ # shared interpreter/tool environments (virtualenvs, pipx,
│ # caches) the Agent creates on demand — a system prompt
│ # convention, not a path the code creates, so tooling is
│ # installed once for any task; project dependencies stay
│ # in the project
├── workspaces/ # temporary Workspaces (tmp-<8hex>)
└── snapshots/ # Agent State version snapshots
For the fields of each config file, see the Configuration Reference.
Trace design
A Trace is an append-only JSON Lines file. Each line is one OmniMessage envelope; see the OmniMessage Protocol. History is only ever appended, never modified in place.
- One Trace file corresponds to one complete model context. When compaction produces a new context segment, the writer rotates to a new file with an incrementing index:
_002,_003, … - Recorded:
session_meta, completemodel_msg, and allevent_msg. - Not recorded:
- Streaming
partial_*fragments. The producer appends the complete message once the segment ends. - Nested messages tagged with
origin. A subagent's messages go to the child Session's own Trace. The parent Trace keeps a singlesubagentpointer event at the spawn site, recording the child Session id.
- Streaming
request_beginandrequest_end(status)come in pairs and delimit one Request. Replay usesrequest_end.status === "completed"as the commit criterion for that turn.- Appends are serialized inside the writer. Records from concurrent producers (the model stream, parallel tool executions) land strictly one after another, each as a single uninterrupted line. A multi-megabyte record, such as a base64 image Data URL, can never be torn apart by a concurrent append. File rotation never splits a record.
- Each record is appended with a single
write(2), notfs.appendFile, which splits payloads larger than 512 KiB into several underlying writes. An abnormal process exit can therefore at most truncate the last record; it can never tear one apart in the middle. - Before Session resumption continues an existing file, the writer probes the file tail. If a previous crash left a torn line (no trailing newline), the next record is preceded by a newline, so the torn line never swallows the records appended after it.
See packages/core/src/trace/writer.ts for the implementation.
Head of a Trace
An illustrative Trace head follows, one OmniMessage envelope per line. Note the order:
- The user's input is written before the
request_beginit is sent with. - What the user-prompt hooks answer follows the user's input directly: a harness-stamped user text per context, or a
hookevent for a hook that failed. - On the first run, the toolset follows the input as a
tool_list_readyevent, after anmcp_connect_begin/mcp_connect_endpair when MCP servers are configured.session_metadoes not carry the tool definitions.
{"timestamp":"2026-07-18T03:10:22.531Z","type":"session_meta","payload":{"session_id":"session-2026-07-18-11-10-22-3f8a1c2d","provider":"deepseek","model_id":"deepseek-v4-pro","model_context_window":1000000,"system_prompt":"…","agent_state":"/home/u/.adelie/data/default_project/agents/default_agent/agent_state","workspace":"/home/u/work"}}
{"timestamp":"…","type":"model_msg","payload":{"type":"text","role":"user","text":"Create hello.txt"}}
{"timestamp":"…","type":"event_msg","payload":{"type":"tool_list_ready","tools":[…]}}
{"timestamp":"…","type":"event_msg","payload":{"type":"request_begin"}}
{"timestamp":"…","type":"model_msg","payload":{"type":"tool_call","role":"assistant","name":"exec_command","arguments":"{\"cmd\":\"printf hi > hello.txt\"}","tool_call_id":"call_0","stop_reason":"completed"}}
{"timestamp":"…","type":"event_msg","payload":{"type":"approval_decision","decision":"allow","tool_call_id":"call_0"}}
{"timestamp":"…","type":"event_msg","payload":{"type":"token_usage","session":{…},"request":{…}}}
{"timestamp":"…","type":"event_msg","payload":{"type":"request_end","status":"completed"}}
{"timestamp":"…","type":"model_msg","payload":{"type":"tool_call_output","role":"user","output":"[no output]","tool_call_id":"call_0","stop_reason":"completed"}}
Truncated tool output
When tool output exceeds maxOutputLength, the Trace records what the model, the Web App and the CLI see: the bounded head, the truncation marker and the absolute Session recovery path. It does not store a second copy of the archived text.
The path exposes the host's data-root layout. It stays valid across Tasks and Session resume, because the unredacted recovery file lives in that Session's scratchpad, and deleting the Session removes the scratchpad and the recovery file together. Replaying the Trace therefore restores both what the model saw and a usable pointer for later follow-up.
Session recovery
The Trace is the single source of truth for recovery. There is no separate session database to keep in sync. resumeSession works as follows:
- Locate the highest-index Trace file of the Session.
- Read the runtime configuration from its
session_meta:- the Workspace, which is immutable for the lifetime of the Session, and the model that context runs on (a model switch opens a new file, so the latest file always names the current model);
- the system prompt that the context opened with.
- Replay the committed history into a fresh LLM context.
- Reconstruct the carry-over (undelivered tool outputs, interruption markers) and the turn and Token counters.
- Continue appending to the same Trace file.
[!NOTE] The thinking level is not part of
session_meta. It resolves again from the Session's pin, else the agent config, else the Project default.
Requirements and guarantees
Recovery requires that the Workspace still exists and the model is still configured in the Project.
Recovery guarantees structural legality:
- Only committed turns are replayed, with
tool_call/tool_call_outputpairing intact. - Incomplete model output (thinking, text) is allowed to be lost.
Damaged files
- A truncated last line left by an abnormal process exit is tolerated and ignored.
- A malformed line in the middle of a file, for example in a file damaged before the writer serialized appends, is skipped with a diagnostic on stderr. Every parseable record is kept.
See packages/core/src/trace/resume.ts.
After a completed compaction
If the latest Trace file ends with a completed compaction, that context is closed as a whole. Resume starts from an empty context.
In summarize mode, the [context_summary] is reconstructed and prepended to the first input after resume. Older Traces using the earlier angle-bracket <summary> form are still understood.
The empty context is opened like any context a compaction opens. It is assembled whole from the current Agent State (prompt, toolset, vault and run settings), not from the closed file's recorded prompt. See Compaction.
An open context behaves differently: it keeps the prompt its file recorded. Its tools, Environment and vault can only come from the current Agent State, because the Trace records no executable configuration.
In-session model switch
The model picker in an active conversation's toolbar switches the model inside the same Session. A switch is a context rotation:
- The context is compacted on the current model, always in summarize mode, even when the agent's
compaction.modeisdiscard: the summary is what reaches the new model. The request is an ordinary compaction request — the current model, system prompt, toolset and parameters, plus one user turn — so it extends the prefix the provider has cached, and nothing about the target model reaches it. - The next context opens on the target model in a new Trace file, whose
session_metarecords that context's model. The file opens as soon as the switch completes, headed by thesession_metaand then the summary, and thatsession_metais also streamed.
The compaction is an ordinary manual one: nothing on the compaction_begin / compaction_end pair names a model. A context with no completed turn has nothing to summarize, so the switch sends no request and records no pair. One that was just compacted hands its held summary to the new file. One whose first request failed or was stopped is left as it is: the summary it opened with, if any, is written again at the head of the new file, and of its other pending input only the text rides on, in memory. A switch carries no image to the new context.
The Session keeps its model when the compaction fails or is aborted by default. A failed compaction can instead give up the context: the caller asks for onCompactionFailure: "discard" (the Web App offers it as a box that is off by default in the switch dialog), and the failed summarize's event pair is followed by a discard pair — the context is dropped whole, nothing further is sent, and the switch completes. This is the only way out of a model that is itself unusable: the summarize request would go to that same model, which cannot compact itself. What it costs is the summary: the conversation's text stays in the transcript and the Trace files, but the new model does not inherit its working memory. An abort is not a compaction failure and never drops a context. The target must be in the Project configuration and constructible (credentials in place), or the switch is refused before any request. A Session that never ran has no context to compact: it switches directly and writes nothing.
Resume reads the model from the latest file, so a Session restarted right after a switch runs on the new model with the summary pending. The summary is still known as the one that file opened with: another switch before the first turn completes writes it on to the next file, restart or not. A switch that dies before its new file exists is lost, the summary is not: the Session resumes on the model it was on, with the summary pending.
For how to use the picker, see Switch the model.
New conversation on another model (/model)
In the Web App, the /model command opens a new Session that continues the conversation on another model and leaves this one as it is. It works the way the /agent handoff does:
- Picking a model stages it in the composer.
- Sending creates a new Session under the same agent through the ordinary session-creation API. The new Session uses the chosen model and the source session's Workspace, so files stay reachable.
- The first message opens with a
[model_switch_from]source block, followed by whatever the user typed. The block records the source session id, the absolute path of its latest Trace file, the Workspace, and the previous model pair.
The history is not injected into the new context. Some models require thinking payloads and fidelity byte-for-byte when history is replayed, and that cannot cross models. Instead, the model reads the source Trace file itself (JSONL, one message envelope per line) when it needs the earlier context; see Field fidelity. The source session and its Trace are untouched. For how to use the command, see Switch the model.
Field fidelity
Each content message carries an opaque provider fidelity payload: thinking signatures, phase labels, encrypted reasoning, and similar data. The Trace preserves this payload verbatim and sends it back verbatim.
- Some models require it byte-for-byte on history replay.
- Any rewriting would break compatibility.
This is one reason the Trace stores raw OmniMessage envelopes rather than a post-processed format.
Observability
Every approval decision, abort, compaction, and Token usage lands in the Trace as an event:
| Occurrence | Event |
|---|---|
| Approval decision | approval_decision |
| Abort | abort |
| Compaction | compaction_begin / compaction_end |
| Token usage | token_usage |
The Web App's Trace views and the usage and cost statistics are all derived from this data. There is no second source of truth.
Both are priced by the same rule: the Project's current rates for the model, at the tier each request's own timestamp fell in. A Trace file's per-turn costs therefore add up to what the conversation header and the Cost Center show for the same requests. See Conversations and the Cost Center.
The approval mechanism itself is covered in Tools & Approval.
The Transport view (the live frames this page received)
The Transport view at the top of the Trace panel records by default, with nothing to switch on first. It records every frame this browser actually received on the live streams and lists them newest first: the SSE event name (message / server_event / ping), the id the channel gave it, its byte length and the opening of its payload — plus connection markers (open / reopen / stalled / live / probe / error / closed) and a silence marker carrying the length of any quiet stretch longer than the server's heartbeat. user on a row marks the GET /api/events stream; the rest belong to this Session.
It holds the receiving half: a frame in the list proves one arrived, and its absence proves nothing about what the server wrote. That is exactly why it exists — when a conversation looks stuck, it is where "the data never arrived" is told apart from "the server never wrote". The view is there in every state of the listing, including a Session with no Trace file yet; whoever does not want it can turn it off, and the choice is remembered in this browser (penguin.sseFrames). The ring keeps the newest 300 entries.
Moving Trace files across deployments
- Export: in a conversation's Trace panel, Export downloads the selected file verbatim as JSONL.
- Import: in Settings → General, Import Trace adds a file to the Project and agent you choose, as a new conversation. Files can be up to 14 MB.
An import whose session id already exists anywhere in this installation is rejected, so an imported file always becomes index 001 of a new Session.