Give each agent its own named session. A name you can type beats a number you have to look up, and one session per task keeps a stuck run from hiding behind another.
tmux new -s api # one session per agent or task
cd ~/code/api && claude # or: codex
# press Ctrl-b then d to detach; the agent keeps running
tmux ls # list sessions
tmux attach -t api # pick it back upOn a remote box, let SSH open the session for you. -A attaches if the session already exists and creates it if not, so the same command works the first time and every time after:
ssh -t devbox tmux new -A -s apitmux keeps the process alive, not the machine. If the box sleeps, reboots or the tmux server is killed, the run stops. The conversation is still on disk, so claude --continue or codex resume --last in the same folder picks it up where it ended. The Claude Code resume guide and the Codex resume guide cover the picker and session IDs.