Keep the agent running after you put your phone away
You put your phone away, the SSH tunnel drops, and the agent dies with it. That is mechanics, not bad luck.
When the connection goes, the pseudo-terminal your login was using is closed. The kernel then sends SIGHUP — hangup — to every process attached to it. That means your shell, and the agent you started inside that shell. Unless a process has gone out of its way to handle that signal, the default is to terminate. Your agent gets no chance to say goodbye, and everything half-finished is thrown away.
tmux lets the session live somewhere else
tmux opens a session on the server. Your agent runs inside that session, not inside the SSH connection that keeps dropping.
When your phone attaches, it is opening a window onto what that session looks like right now. When the connection drops, the window is what disappears. The session stays on the server, the agent in it carries on, and nothing was interrupted.
Detach and attach are the same as turning off a television
Switch a TV off and the picture in your living room is gone. The broadcast never stopped. Turn it back on and you are on the same channel, wherever it has got to by now.
tmux calls those two actions detach and attach — close the window, open it again. Neither touches what is running on the machine.
What this means for an agent
You lose signal on the train. Again in a lift. Again switching Wi-Fi. Attach to the same tmux session each time and you can drop ten times without the agent being interrupted once. It does not know you ever disconnected. It was never living inside your connection.
Knowing what tmux is for is enough. Agentmux handles the installing — once it connects, it works out whether your machine uses apt, dnf, pacman, or brew, and sets it up for you.
So the agent survives. One question left: how do you get in from outside?