# Sessions and context
Sessions preserve conversations so you can leave, resume, branch, export, and manage context.
## Start or resume work
Running `magi-code` creates a saved session by default.
```sh
magi-code --continue
magi-code --resume <SESSION_ID>
magi-code --no-session
```
- `--continue` opens the most recent session.
- `--resume` opens a specific session.
- `--no-session` keeps no resumable conversation history.
Inside Mission Control, `/sessions` lists saved sessions and `/new` starts another one.
Wait for the current run to finish before using `/new` or `/sessions`. `/new` restores startup model and thinking defaults.
Explicit `/model` and thinking choices belong to the current saved session, not global defaults. Resume uses cached model availability. If restoration fails, the destination default model remains active, a warning explains why, and the saved preference remains intact. Unsupported requested thinking resolves to the active model's supported default.
## Manage context
Long conversations eventually approach a model's context limit. `/compact` asks a provider to summarize earlier work, then continues from that summary. Local history remains available even though future provider requests use compacted context.
Automatic compaction can be configured under `/settings` → **Context**. Keep it enabled for long-running work unless you need manual control over every compaction.
Compaction uses a provider call and can consume quota.
## Rewind work
Enter `/changes` to inspect captured file changes. `/rewind` offers conversation only, files only, or both. Conversation rewind creates a new session before the selected prompt and preserves the original.
File restore covers captured `write` and `hash_edit` changes, not shell commands or external edits. Later user edits can cause conflicts; review the reported result.
## Export a session
Enter `/export` while idle. Magi-code writes a ZIP containing the raw session and related history.
Exports are unencrypted and may include prompts, responses, tool data, repository paths, and source content. Inspect an export before sharing it.
## Delete old sessions
```text
/prune-sessions
/prune-sessions 7
```
The default removes sessions older than 30 days. Supplying a number changes the cutoff. Active sessions remain. Deletion is permanent for resume purposes.
## Progress summaries
Open **Summary** or press `Alt-3`, then choose **Start**. The session summarizer turns recent activity into short progress entries.
Summarizing makes additional provider calls and sends recent session activity after redaction. It is a progress view, not a complete audit and not a replacement for compaction.
To enable it automatically, set:
```json
{
"agent": {
"summarizer": { "auto_start": true }
}
}
```
You can select a separate summarizer provider, model, reasoning level, and replacement prompt in settings.
## Progressive Session Maintenance
For background summaries of saved events, open `/settings` → **PSM** and enable **Progressive Session Maintenance**. Choose an event threshold and, optionally, a separate summary model and reasoning level. Save with `Ctrl-S` and restart to apply the settings.
PSM writes a separate file beside each observed session. It makes additional provider calls with full tracked records, including tool results. Conversation context and compaction remain unchanged. Failed batches retry at a later trigger. See [Progressive Session Maintenance](../features/progressive-session-maintenance.md) for scope, privacy, and limits.
## Advanced reference
See [Sessions, context, and cache](../features/sessions-context-cache.md) and [Session summarizer](../features/session-summarizer.md) for retention, checkpoint, export, compaction, storage, and provider-call details.