M31A stores conversations as JSONL files managed by packages/core/src/services/chatRecordingService.ts. Types are defined in chatRecordingTypes.ts.
Storage layout
Main sessions live in the project temp directory under chats/:
<temp>/<project-id>/chats/session-<YYYY-MM-DDTHH-MM>-<session-id-prefix>.jsonlSubagent sessions are nested under <chats>/<parent-session-id>/ and named with the sanitized session id plus .jsonl. Filename collisions get -1, -2, and so on. Legacy .json files are normalized to .jsonl on load.
Envelope
The first line is metadata; each following line is a message or control record. Writes are append-only, one JSON object plus a newline per line.
{
"sessionId": "8f1c...",
"projectHash": "....",
"startTime": "2026-11-30T10:00:00.000Z",
"lastUpdated": "2026-11-30T10:05:00.000Z",
"messages": [],
"summary": "optional summary",
"directories": [],
"kind": "main"
}kind is main or subagent. Optional memoryScratchpad has version: 1 and may contain workflowSummary, toolSequence, touchedPaths, and validationStatus of passed, failed, or unknown.
Message records
| Field | Meaning |
|---|---|
id | UUID for the message. |
timestamp | ISO timestamp. |
content | Structured content parts. |
displayContent | Optional presentation form. |
type | user, info, error, warning, or gemini. |
A gemini message may add toolCalls, thoughts, tokens, and model. tokens has input, output, cached, total, and optional thoughts and tool counts.
A tool call record contains id, name, args, result, status, timestamp, and optional agentId, displayName, description, resultDisplay, and renderOutputAsMarkdown.
Control records
| Record | Effect |
|---|---|
{ "$rewindTo": "<messageId>" } | Truncate messages from that id onward. |
{ "$patch": { ... } } | Apply content, tool-call, ordering, or removal patches. |
{ "$set": { ... } } | Update metadata. Also used by legacy full-history checkpoints. |
A record with sessionId and projectHash | Partial metadata update. |
$patch may specify id, content, toolCalls, updates, removeIds, and orderIds. Legacy $set checkpoints are deprecated in favor of $rewindTo.
Limits and recovery
- The in-memory history window is capped at 50 messages.
- Tool output is capped at 50 KiB per record.
- Recovery rewrites files atomically through a
.tmp-<pid>file and rename. Unreadable files are preserved as.unreadable-<timestamp>.
Working with sessions
m31a --list-sessions
m31a --resume latest
m31a --session-file /path/to/session.jsonl
m31a --delete-session 3In the TUI: /chat list, /chat checkpoints, /rewind, /restore, and /export-session. See Sessions and context.
Caution
Session files can contain prompts, file contents, and tool output. Redact secrets before sharing them in issues or pull requests. See the Runbook.
Next steps
See Session storage and Settings for retention configuration.