Skip to content

M31A keeps conversation history locally. Nothing about a session is sent to a remote storage service; the only network call is the model request described in The agent loop.

The main implementation files are:

FileResponsibility
packages/core/src/config/storage.tsResolves global and per-project paths.
packages/core/src/services/chatRecordingService.tsAppends records to the session file.
packages/core/src/services/chatRecordingTypes.tsDefines the record shapes.
packages/core/src/utils/checkpointUtils.tsMaps restorable tool calls to snapshots.
packages/core/src/services/gitService.tsCreates and restores shadow-Git snapshots.
packages/core/src/services/sessionSearchIndex.tsSQLite + FTS5 search index.

1. Where records live ​

Global configuration lives in ~/.m31a (or M31A_HOME). Runtime state uses ~/.m31a normally; under macOS Seatbelt it is redirected to ~/.cache/.m31a because the home directory is not writable by the profile.

Per-project state lives under a hash-derived project temp directory returned by Storage.getProjectTempDir(). Inside it:

text
<project-temp>/
  chats/
    session-20260101-1200-abcd1234.jsonl   # main sessions
    <parent-session-id>/
      <subagent-session-id>.jsonl          # nested subagents
  checkpoints/
  logs/
  tool-outputs/
  memory/
  plans/
  tracker/

New sessions are named session-<timestamp>-<short-id>.jsonl. Legacy .json records are migrated to .jsonl on resume. A session ID can also be supplied with --session-id or loaded from --session-file.

2. What is stored ​

A ConversationRecord contains:

  • sessionId, projectHash, startTime, lastUpdated, and kind (main or subagent);
  • directories added during the session;
  • messages, each with an ID, timestamp, role (user, model turns named gemini, info, error, warning), content parts, and optional display content;
  • tool calls with ID, name, arguments, result, status, timestamp, and optional agent ID;
  • thoughts and token summaries attached to model turns;
  • an optional summary and memoryScratchpad with workflow metadata;
  • patch records ($patch), rewind markers ($rewindTo), and metadata updates ($set).

Writing is append-oriented: new records are appended, and in-place changes such as a tool result arriving after a scheduled call are represented as patches. This keeps a durable trail and allows recovery from an interrupted process. Scheduled tool calls are recorded before execution for exactly that reason.

3. Listing, resuming, exporting ​

bash
m31a --list-sessions
m31a --resume latest
m31a --resume 5
m31a --session-file /path/to/session.jsonl
m31a --session-id my-custom-id
m31a --delete-session 3

--resume, --session-id, and --session-file are mutually exclusive. Inside the app, /chat list|save|resume|delete|share|checkpoints, /resume, /clear, and /export-session cover the same ground.

On resume, M31aChat reconstructs history with the canonical converter so tool calls and thought parts survive the round trip. See Sessions and context for the user-facing commands.

4. Checkpoints and rewind ​

Checkpointing is opt-in:

json
{
  "general": {"checkpointing": {"enabled": true}}
}

When enabled, GitService maintains a shadow Git repository independent of your project's Git history. Before a restorable edit, it creates a file snapshot commit and keeps it reachable under refs/m31a/checkpoints/.... processRestorableToolCalls() maps each tool call to a checkpoint file named from the timestamp, file name, and tool name.

  • /chat checkpoints lists available snapshots.
  • /rewind returns the conversation to an earlier message.
  • /restore restores files from a selected snapshot.

Restores are transactional: the service commits a pre-restore backup under refs/m31a/restore-transactions/... and rolls back to it if the restore fails. Git must be installed for checkpointing; if it is missing, startup fails with an explicit error rather than silently disabling the feature.

5. Retention ​

general.sessionRetention controls startup cleanup:

KeyDefaultMeaning
enabledtrueRun cleanup at startup.
maxAge30dDelete sessions older than this.
maxCountunsetKeep at most this many recent sessions.
minRetention1dSafety floor; younger sessions are kept.

Durations accept h, d, w, and m suffixes. Cleanup requires at least one of maxAge or maxCount; invalid values are rejected. Deleting a session also removes its logs, spilled tool outputs, and nested subagent directories. Spilled tool outputs have their own cleanup path with a default age of seven days.

WARNING

Retention deletes local records. Export anything you need with /export-session before tightening maxAge or maxCount.

6. Session search index ​

The session_search tool searches across past sessions using a SQLite FTS5 index at ~/.m31a/sessions-fts.sqlite. It indexes session metadata, summaries, and message text from the project's chats/ directory, with a porter unicode61 tokenizer and WAL journaling.

node:sqlite is required, so full-text search is available on Node.js 22 or newer even though M31A itself supports Node.js 20. On Node 20 the tool returns a clear message instead of crashing. Results include the session ID, timestamp, summary, and a matching snippet.

This index is separate from the session files: deleting a session file also removes its artifacts, and the index is refreshed from the directory when the tool runs.

7. Privacy considerations ​

Session records include full message content, tool arguments, and tool results. Tool output masking and distillation reduce what is sent to the model, not necessarily what is written to disk. Spilled output files live under tool-outputs/ and are cleaned up by age.

Keep credentials out of prompts and tool arguments. Use security.environmentVariableRedaction for environment-derived content, and advanced.excludedEnvVars or advanced.ignoreLocalEnv to keep .env values out of project context. See Sandbox hardening.

Next steps ​

Built with VitePress. Powered by NVIDIA NIM.