Skip to content

Session state and restore

Nagi has several state paths. They solve different problems.

CaseProcesses keep runningLayout returnsRecent screen returnsAgent conversation resumes
Detach and reattachYesYesYes, from the live terminalYes, because the process never stopped
Server restartNoYesOnly with pane screen historyOnly with native agent session restore
Update without --handoffCompatible servers keep running; restart-required servers may need stop/restartYes after restartOnly with pane screen historyOnly with native agent session restore
Update with --handoffBest effort for supported running serversYesYes, from the live terminal if handoff succeedsYes, because the process keeps running if handoff succeeds

The sections below explain each path.

Normal detach keeps the Nagi server running. Panes, shells, agents, servers, tests, and command processes keep running inside that server.

Detach the client with ctrl+b q. Reattach later:

Terminal window
nagi

This is the strongest persistence path because the original processes never stop.

If the Nagi server stops and starts again, the original pane processes are gone. Nagi restores the saved session shape: workspaces, tabs, panes, cwd, layout, and focus.

Snapshot restore does not preserve running shells, servers, tests, or arbitrary processes. Panes that cannot use a stronger restore path come back as new shells in their saved directories.

Pane screen history restores recent terminal contents after a full server restart. It restores what Nagi can show, not the old process.

This is off by default because pane output can include secrets, tokens, prompts, and command output. Enable it from Settings > Experiments > pane screen history or with:

[experimental]
pane_history = true

When enabled, Nagi stores saved pane history in session-history.json next to session.json. Treat the Nagi config/session directory like terminal history.

Some agents can resume their own conversation sessions. Nagi can use official integration-reported session references to restart supported agent panes after a Nagi server restart.

This is enabled by default. Disable it with:

[session]
resume_agents_on_restore = false

Nagi only resumes panes that reported a native session reference through a current official Nagi integration.

After a client attaches and provides terminal size and theme context, Nagi resumes eligible restored agent panes across workspaces and tabs without waiting for each pane to be focused.

Native session restore requires these Nagi integration versions or newer:

AgentMinimum Nagi integration versionResume command
Pi2pi --session <path-or-id>
OMP3omp --resume=<path-or-id>
Claude Code6claude --resume <id>
Codex5codex resume <id>
Cursor Agent CLI1cursor-agent --resume <id>
GitHub Copilot CLI2copilot --resume=<id>
Devin CLI2devin --resume <id>
Droid2droid --resume <id>
Kimi Code CLI3kimi --session <id>
Qoder CLI2qodercli --resume <id>
OpenCode5opencode --session <id>
Kilo Code CLI1kilo --session <id>
Hermes Agent2hermes --resume <id>
MastraCode1mastracode --thread <id>

Run nagi integration status to check installed integration versions. Reinstall outdated integrations with nagi integration install <agent>.

Unsupported, missing, invalid, duplicated, or stale session references restore as normal shells in the saved pane directory.

If native agent session restore applies to a pane, Nagi resumes the agent session instead of replaying saved pane history for that pane.

Live handoff is for update and remote attach flows that need to replace a running Nagi server. It asks the old server to transfer live panes to the new server, so pane processes can keep running across the server replacement.

This is different from snapshot restore, pane history replay, and native agent session restore. Handoff tries to keep the current processes alive. The others reconstruct state after the old server has already stopped.

Live handoff is experimental and opt-in:

Terminal window
nagi update --handoff
nagi --remote workbox --handoff

Plain nagi update and plain nagi --remote workbox use the normal restart/stop flow by default.

nagi update --handoff is retained in the inherited runtime, but Nagi’s automatic update channel is disabled until the project publishes signed artifacts. Rebuild reviewed source and restart the session instead.