﻿---
title: Agents that outlive Heed
description: Keep agents running when Heed quits, restarts or updates, with zmx.
url: https://docs-v3-preview.elastic.dev/sessions/zmx
---

# Agents that outlive Heed
Install [zmx](https://zmx.sh) and every pane runs in a zmx session that Heed attaches to. Quitting, restarting or
updating Heed leaves the agents running, mid-turn if they were, and the next launch reattaches: same screen, same
scrollback, nothing started again. Without zmx, a pane's terminal belongs to Heed: quitting stops its agent, and the
next launch [resumes](https://docs-v3-preview.elastic.dev/sessions/resume) it from its own history.
zmx is yours to install; Heed does not ship it. On this Mac:
```sh
brew install neurosnap/tap/zmx
```

(or any way [zmx.sh](https://zmx.sh) describes). Heed picks it up on its own:
```toml
[sessions]
persist = "auto"  

[tools]
zmx = ""          
```

**Settings › Tools** shows zmx's check, next to git and gh: where it found zmx, its version, and whether it
works the way Heed uses it (`zmx version`, then listing Heed's own sessions). It also says whether panes run in zmx
because of it. With `auto`, a zmx that is missing or fails its check leaves panes as plain shells. With `zmx`, Heed
uses it whenever it is there, and says how to install it when it is not.
![Settings › Tools, the zmx row: its path field, /opt/homebrew/bin/zmx 0.8.1 works, and Panes run in zmx: agents outlive heed](https://docs-v3-preview.elastic.dev/images/shots/configuration/tools-zmx.png)
The setting applies to panes opened from then on; panes already open keep going as they are until they close.
![The strip over a session on a host: @devbox, its path, and the link line in green, connected with zmx, so the session outlives the link](https://docs-v3-preview.elastic.dev/images/shots/sessions/host-strip.png)
![A session row for a session on @devbox: its title, repo chip, host chip and state](https://docs-v3-preview.elastic.dev/images/shots/sessions/row-host.png)

## What changes


|                                                | without zmx (`none`)                                | with zmx                                                                              |
|------------------------------------------------|-----------------------------------------------------|---------------------------------------------------------------------------------------|
| Quit Heed with agents working                  | Asks first; the agents stop                         | Quits; the agents keep going                                                          |
| Next launch                                    | Resume dialog: each agent restarts from its history | Panes reattach to the running agents; only ones that are gone (after a reboot) resume |
| `exit` in a pane                               | The pane closes                                     | The same                                                                              |
| Close or delete a session, clean up a worktree | Its terminals end                                   | Its zmx sessions end too, so nothing is left running                                  |

`:agents.stop` ends every agent and shell in every pane at once, when you want them all gone (Heed asks first).
Sessions stay; their panes come back as shells.

## Details

- Heed keeps its sessions apart from any you run yourself: they live in
  `~/Library/Application Support/Heed/zmx` and are named `heed-<pane>`. `ZMX_DIR` set to that folder lets you
  `zmx list` or `zmx attach heed-<pane>` them from another terminal.
- zmx's own detach key (`⌃\`) is off in Heed's sessions: `⌃\` is Heed's way out of INSERT.
- Keys, the mouse and terminal modes pass through untouched, and a reattached pane is told the modes its program had
  on (keyboard protocol, mouse, bracketed paste).
- zmx is a separate project by Eric Bower ([zmx.sh](https://zmx.sh)). Heed only calls the zmx you installed.