I build mAGI. The category line: Omarchy makes Linux beautiful for humans; mAGI makes Linux a workstation for agents. In practice that's a Fedora/Hyprland image where you work through one agent (Claude Code, opencode, Codex or another terminal agent) running in tmux, and it starts other agents in their own tmux windows, often several at once.
tmux keeps those alive when you close the terminal. It doesn't keep them across a reboot. After a kernel update you get an empty server, and each agent conversation has to be found and resumed by hand, if you remember which ones were open and where.
mAGI does that part with three small pieces.
1. A snapshot every minute
tmux-snapshot runs from a systemd user timer every minute. For every window it saves the session, index, name and each pane's working directory, plus how to restart that pane:
- agent panes get the agent's resume command with the same flags:
claude --resume <id>,opencode --session <id>,codex resume <id>. The session id comes from the agent's own state (for Claude Code,~/.claude/sessions/<pid>.json), not from scraping the screen. - the orchestrator gets
magi-agent orchestrator --resume - panes started with a command (a dev server, the voice listener) get that command
-
nvimpanes getnvim - anything else gets a shell in the same folder
It writes ~/.local/state/tmux-snapshot/layout.json and keeps the last 30 copies. It never writes a snapshot while the tmux server is down, so a fresh boot can't overwrite the layout before it has been restored.
2. A restore at login
tmux-restore.service runs once at login and rebuilds the layout:
$ tmux-restore --dry-run magi:orchestrator <- magi-agent orchestrator --resume in ~ magi:api-refactor <- claude --resume 3f1c9a2e-7b44-… in ~/code/api magi:blog-draft <- opencode --session ses_8a71c2 in ~/notes magi:notes <- nvim in ~/notes magi:dev-server <- npm run dev in ~/code/web It's idempotent: a window is only created if its session doesn't already have a window with that name, so it's safe if you opened a terminal first. Each command is followed by exec bash, so when an agent exits you land in a shell in the same folder instead of a closed pane. The unit uses KillMode=process so restarting it doesn't take the tmux server down with it.
3. Closing idle agents without losing them
Idle agents still hold memory. tmux-reap-stale closes an agent only when all of these hold: its state is idle (from the agent's own files where it has them), it has been idle for 60 minutes (20 when memory is short), it isn't the orchestrator, there's no question or permission prompt on screen, and nothing is typed in its input box.
Each close is logged with its resume command, and it becomes an unticked line in today's daily note:
## Open threads - [ ] api-refactor (auto-closed, idle 61m) · resume: claude --resume 3f1c… Every three hours the orchestrator is reminded of unticked threads and brings them up, so a closed session is a to-do, not something that quietly disappears.
What it doesn't do
It restores the conversation, not process state. A half-finished shell command inside an agent's tool call is gone. Agents without a resume command start fresh in the right folder. And if an agent update changes the files mAGI reads, the reaper treats that agent as busy and closes nothing.
Code: tmux-snapshot, tmux-restore, tmux-reap-stale. They're plain Python; outside mAGI they need tmux, systemd and the repo's agent/lib. MIT licensed.
Part 1 of this series was the event bus the agents use to report back.
