Skip to main content
blog.philz.dev

tmux For Agents

ctrl-b

If you're working on a web thing, you gotta give your agents a browser. If you're working on a an interactive tool, you can give your agents tmux. With send-keys and capture-pane, the agent can operate gdb, use an interactive terminal, and so on. I asked the LLMs for a markdown file to explain it to the agent, but you can basically just mention stuff like the following, and the agents have enough in their training data.

tmus new-session -d -s testing
tmux new-window -t testing -n sh 'bash'
tmux send-keys -t testing:foo 'make' C-m
tmux capture-pane -p -t testing:foo

At first, I thought I'd write my own thing, named unreadline to allocate a pty and let the agent read/write to it, but it turns that tmux works better. And there's an old (2005-2009) thing called empty which in turn was based on ptyget or pty4 by djb, in the mid 90's. There's also expect.

It turns out I've been recommending tmux screen since ~2004.