Overview
The tmux runtime creates detached tmux sessions for each agent, allowing you to:- View agent activity in real-time by attaching to sessions
- Keep agents running even if you disconnect
- Send commands to agents via stdin
- Capture terminal output for activity detection
Tmux sessions persist independently of the orchestrator. If the orchestrator crashes, agents continue running.
Configuration
To use the tmux runtime, configure it in youragent-orchestrator.yaml:
Requirements
Tmux must be installed and available in PATH
Runtime API
The tmux plugin implements the standard Runtime interface:create(config)
Creates a new tmux session and runs the launch command.Session identifier (must match
[a-zA-Z0-9_-]+)Working directory for the session
Command to execute on session start
Environment variables to set in the session
sendMessage(handle, message)
Sends a message to the agent by writing to stdin and pressing Enter.For messages longer than 200 characters or containing newlines, the plugin uses tmux’s
load-buffer + paste-buffer to avoid shell truncation issues.getOutput(handle, lines)
Captures the last N lines of terminal output from the pane.Number of lines to capture from the scrollback buffer
destroy(handle)
Kills the tmux session, terminating all processes running in it.Session cleanup is best-effort. If the session is already dead,
destroy() returns without error.isAlive(handle)
Checks if the tmux session exists.getAttachInfo(handle)
Returns the command to attach to the session:Usage Examples
Attach to a Running Session
View Session Output
Kill a Stuck Session
Advanced Features
Long Command Handling
For commands exceeding 200 characters, the plugin uses a two-step process:- Write command to a temporary file
- Load into tmux buffer and paste
- Clean up temp file
Environment Variables
All environment variables specified inconfig.environment are passed to the session using tmux’s -e KEY=VALUE flag.
Pane Capture
ThegetOutput() method uses tmux capture-pane -p -S -N to extract the last N lines from the scrollback buffer, providing a snapshot of recent terminal activity.
Troubleshooting
Session creation fails with 'invalid session name'
Session creation fails with 'invalid session name'
Cause: Session ID contains invalid charactersSolution: Ensure session IDs only contain
[a-zA-Z0-9_-]Command truncation or mangled output
Command truncation or mangled output
Cause: Very long commands (>200 chars) or special charactersSolution: The plugin automatically handles this using buffer-based paste. If issues persist:
- Check for unescaped special characters in the launch command
- Verify tmux version >= 2.0
- Use
shellEscape()from@composio/ao-corefor dynamic commands
Cannot attach to session
Cannot attach to session
Cause: Session may have exited or you’re using a different tmux serverSolution:
Process keeps running after destroy()
Process keeps running after destroy()
Cause: Tmux session killed but child processes detachedSolution: Ensure launch commands don’t use
nohup or & to background processes. If needed, use the process runtime plugin instead.Comparison with Process Runtime
| Feature | Tmux | Process |
|---|---|---|
| Persistence | Survives orchestrator restarts | Dies with orchestrator |
| Attachment | Full terminal via tmux attach | No interactive attachment |
| Overhead | Higher (tmux server + session) | Lower (direct child process) |
| Use Case | Interactive debugging, long-running agents | Headless automation, CI/CD |
Use tmux for development and debugging. Use process runtime for production deployments where you don’t need to attach to sessions.
