Sessions & Autosave

Automatic session persistence, encrypted storage, and state recovery.

Autosave

Your session is automatically saved after every step. No manual action needed.

When does it save?

  • TUI mode: After each completed step (tool execution, model response)
  • Chat mode: After each message exchange

Where is it stored?

macOS: ~/Library/Application Support/m/sessions/
Linux: ~/.config/m/sessions/

The session is stored as an encrypted JSON file named _autosave.

Encryption

Sessions are encrypted using AES-256-GCM. The encryption key is stored in your OS keychain:

  • macOS: macOS Keychain
  • Linux: libsecret

The key is generated on first use and never leaves your machine.

What's saved?

  • All messages (user, assistant, tool calls, tool results)
  • Provider and model used
  • Token usage (input/output)
  • Everything needed to reconstruct the session state

Session Management

/save [name]

Create a snapshot of the current session. Without a name, it's timestamped. With a name, it's easy to find later.

» /save
session saved: 2025-07-04_12-30 (8 messages)

» /save fixing-auth-bug
session saved: 2025-07-04_12-30_fixing-auth-bug (8 messages)

/sessions

List all saved sessions (including autosave and named snapshots).

» /sessions
saved sessions (2):
  1) _autosave
  2) 2025-07-04_12-30
use /resume <id or number> to restore

/resume <id or number>

Restore a previously saved session. You can use the session id or the number from /sessions.

» /resume 1
resumed session _autosave (12 messages, alibaba/deepseek-v3.2)
» continue where we left off

/reset

Clear the current conversation history and start fresh. The autosave is preserved separately — you can /resume _autosave to get it back.

Graceful shutdown & crash recovery

Graceful shutdown

When you press Ctrl+C or the process receives SIGTERM, the session is automatically saved before exit. No data is lost.

Crash recovery

If the app crashes, your session is already saved (autosave runs after every step). On next launch:

» /sessions
saved sessions (1):
  1) _autosave

» /resume 1
resumed session _autosave (12 messages, alibaba/deepseek-v3.2)

The _autosave session is overwritten after every step, so it always has your latest state.

Best effort

Autosave is best effort — if saving fails (disk full, permissions, etc.), the error is silently ignored. For critical work, always use /save explicitly or keep backups of important sessions.

Privacy

  • Sessions are never sent to any external service
  • All data stays on your machine
  • Encryption key lives in your OS keychain, not in config files
  • The _autosave file is overwritten on each autosave, not appended