Sessions & Context

MiMo Code persists every conversation as a session, retaining its message history and metadata. You can close the terminal and resume your work later. This page covers how sessions are stored, resumed, switched, and forked, as well as how the context window is managed through compaction.


Session storage

Session data is saved in MiMo Code's data directory, grouped by working directory.

$MIMOCODE_HOME/ ├── config/ ← global config files ├── data/ ← auth.json, session database ├── state/ └── cache/

MIMOCODE_HOME is an absolute path to a single profile root holding the config/, data/, state/, and cache/ subdirectories; setting it overrides all four XDG base directories.

WARNING

Don't edit these files manually. Session state is managed by MiMo Code, and manual changes may make a session unrecoverable.

When uninstalling, use mimo uninstall --keep-data to keep session data and snapshots. Learn more.


Starting and resuming sessions

Running MiMo Code creates a new session in the current directory.

mimo

You can resume an existing session with the following flags:

# Resume the most recent session in the current directory
mimo --continue

# Resume a specific session by ID
mimo --session <id>
FlagShortDescription
--continue-cContinue the last session
--session-sSession ID to continue
--forkFork the session when continuing (use with --continue or --session)
NOTE

--continue and --session cannot both specify a new session source at once; --forkmust be used together with one of them.

See the full list of CLI flags in Command Line.


Switching sessions in the TUI

Inside the TUI, you can switch between sessions using slash commands:

  • /new (alias /clear) — start a new session, discarding the current context. Keybind ctrl+x n.
  • /sessions (aliases /resume, /continue) — list and switch between sessions. Keybind ctrl+x l.

See the full list of slash commands in Slash Commands.


Listing sessions

Outside the TUI, use the session command to manage sessions.

mimo session list
FlagShortDescription
--max-count-nLimit to the most recent N sessions
--formatOutput format: table or json (default table)

Context compaction

Every model has a limited context window. As a conversation grows, the MiMo Code CLI automatically compacts earlier messages as the context approaches that limit to free up token space. You can also trigger it manually at any time:

none
/compact

/compact has the alias /summarize and the keybind ctrl+x c.

Compaction is performed by a hidden Compaction agent that compresses long context into a smaller summary.

Configuration

You can control context compaction behavior through the compaction option.

mimocode.json
{
  "$schema": "https://mimo.xiaomi.com//config.json",
  "compaction": {
    "auto": true,
    "prune": true,
    "reserved": 10000
  }
}
  • auto - Automatically compact the session when context is full (default: true).
  • prune - Remove old tool outputs to save tokens (default: true).
  • reserved - Token buffer for compaction. Leaves enough window to avoid overflow during compaction.

To disable automatic compaction entirely, set the environment variable MIMOCODE_DISABLE_AUTOCOMPACT=true. Learn more.


Forking sessions

Forking lets you derive an independent copy of a session to try new ideas without affecting the original. The two sessions are independent and don't affect each other.

# Fork from the most recent session and continue
mimo --continue --fork

# Fork from a specific session
mimo --session <id> --fork

When running through the HTTP interface, you can also fork an existing session at a specific message..


Exporting and importing

You can export a session to JSON for archiving, sharing, or bug reports.

mimo export [sessionID]

If you don't provide a session ID, you'll be prompted to choose from the available sessions.

You can then import session data from a local file or a MiMo Code share link.

mimo import session.json
mimo import https://opncd.ai/s/abc123
TIP

Exported files may contain sensitive information (code, command output, paths, etc.). Review the contents before sharing.

To share a session live via a link, see Share.