Tmux Session Persistence
A "session backend" is how botmux hosts the CLI process. The default backend is tmux: each topic's CLI runs inside a tmux session, so when botmux itself restarts, the CLI keeps running.
So the most common question, "will restarting botmux lose my context?", has a simple answer: no.
What happens to a session in each case
Two terms first:
- Re-attach: the CLI process stayed alive and botmux simply reconnects to it. Context is intact and no extra tokens are spent.
- Cold resume: the CLI process is gone. When the next message arrives, botmux starts a new process from the CLI's own saved conversation (for example Claude Code's
--resume). The topic and context are kept; it just takes a few more seconds.
Enter a session from your local terminal
The easiest way is botmux list:
Keys in the list:
You can also use tmux directly:
Press Ctrl+B, then D to leave; the CLI keeps running in the background.
What you see inside is an ordinary terminal, exactly like running the CLI locally. The Lark topic, the Web terminal and your local tmux all show the same process, and actions on any side stay in sync.
Why botmux uses its own tmux server
botmux sessions live on a dedicated tmux server (tmux -L botmux) instead of mixing with your own tmux. So whether you slip, or a bot runs tmux kill-server inside its own terminal, only your own sessions on the default server are closed, not every bot session at once.
- Old sessions that were running before the upgrade stay on the default server (
tmux attach -t bmx-…still works) and move to the dedicated server the next time they have to be created again (for example a CLI restart or a cold resume).botmux list, the Web terminal and the Dashboard terminal page find each session wherever it lives. /adoptis unaffected: it takes over terminals you opened on your default server; see Session Adoption (Adopt).- To get the old behaviour back, set
BOTMUX_TMUX_SOCKET=defaultin~/.botmux/.env; new sessions then go back to the default server. You can also pick another name (letters, digits and_.-only); an invalid value falls back tobotmux, never silently to the default server. TMUX_TMPDIRworks as usual; the socket file is$TMUX_TMPDIR/tmux-<uid>/botmux.
tmux is missing or doesn't work
- Auto-install: when
botmux start/botmux restartcan't find tmux, it first tries to install it for you, and if that fails it prints a manual install command and stops (unless you explicitly setBACKEND_TYPE=pty). See Prerequisites. - No silent backend switch: if tmux doesn't work when a new session starts, botmux refuses to start it and posts a card in Lark with the reason and the install command (
brew install tmuxon macOS,sudo apt-get install -y tmuxon Debian/Ubuntu). - tmux is installed but won't start: this usually means a container's seccomp/sandbox policy blocks the
clone3/clonesystem calls. In that case the card doesn't ask you to install tmux; it tells you to allow those two system calls. - Emergency workaround: the card mentions
BACKEND_TYPE=ptyas a temporary bypass, but pty sessions don't survive a botmux restart. - Sessions that are already running are not affected by a single failed probe and can still be re-attached.
Switch to another backend
Day to day you only need tmux. If you really need to switch, use the BACKEND_TYPE environment variable globally, or backendType in bots.json for a single bot (see bots.json configuration):
A few things to keep in mind:
- Only new sessions are affected: each session remembers the backend it was created with, so existing sessions don't move when you change the setting.
- Bots with the sandbox enabled can only use
tmux,hcorpty.herdr,zellijandzmxdon't support the sandbox's file isolation and are blocked before launch; see Sandbox. - Remote-style CLIs bring their own backend:
riff,mojoandremote-runnerdon't run a process on this machine, so the backend automatically follows the CLI; you don't (and can't) set it separately. Conversely, if an ordinary CLI is configured with one of these backends, it automatically falls back to a local backend.
herdr: where sessions are placed
With the herdr backend, by default each topic gets a new workspace in the herdr session botmux, which botmux manages itself. To have bot sessions show up in the herdr you are already using, change the placement.
There are two places to configure it. They are merged field by field, and bots.json wins:
- Whole machine:
BOTMUX_HERDR_SESSION_NAME,BOTMUX_HERDR_PLACEMENT,BOTMUX_HERDR_WORKSPACE,BOTMUX_HERDR_TAB,BOTMUX_HERDR_SPLIT_DIRECTIONandBOTMUX_HERDR_CHAT_TYPES(comma-separated, e.g.group,p2p) in~/.botmux/.env. - Single bot: the
herdrblock in bots.json. Fields you set override the matching environment variable; fields you leave out keep the environment value.
A few things to keep in mind:
- You need at least
sessionNameorplacement(after merging both places). Setting only sub-fields such asworkspaceortabdoes nothing; sessions still get a new workspace in the defaultbotmuxsession. - Only new sessions are affected; existing sessions stay where they are.
- When sessions go into your own herdr session, closing a topic only closes the bot's own pane, never your session.
