Skip to main content

tmux Integration

tmux is the transport layer for all Genie agents. Every spawned agent runs in a tmux pane, receives messages via send-keys injection, and is monitored through pane content capture. Understanding the tmux structure helps with debugging and manual intervention.

Session Architecture

Naming Conventions

Agent Lifecycle in tmux

Spawn

When genie spawn engineer runs:
  1. Find or create the tmux session (based on team or default)
  2. Create a new window named after the agent role
  3. Launch Claude Code in the window’s pane with the appropriate arguments
  4. Register the agent in the agent registry with the pane ID

Message Delivery

Messages are injected into panes using tmux send-keys:
Delivery only happens when the agent is detected as idle (at a prompt). The orchestrator detects state by capturing pane content and pattern-matching for prompt indicators.

State Detection

The orchestrator captures pane content to determine agent state:
State is inferred from the captured output:

Kill and Suspend

Killed agents transition to suspended in the registry. Their session ID is preserved for potential resume.

Session Management

Current Session

Genie detects the current tmux session through a fallback chain:
  1. Inside tmux ($TMUX set) — use display-message for authoritative session name
  2. Outside tmuxlist-sessions, prefer session matching a hint (team name)

Auto-Create

When session.autoCreate is true (default), Genie automatically creates the tmux session if it doesn’t exist. This means genie spawn works even if tmux has no sessions.

Team Sessions

Each team gets its own tmux session (or window group). The session name is derived from the sanitized team name:

Keyboard Shortcuts

Install shortcuts with genie setup --shortcuts or genie shortcuts install.

tmux Shortcuts

Shell Aliases

Mosaic Layout

For teams with multiple agents, Genie supports a mosaic layout that tiles all agent panes in a single view:
The mosaic layout is computed by mosaic-layout.ts and applied via tmux select-layout.

Configuration

tmux-related settings in ~/.genie/config.json:

Troubleshooting

Agent Not Receiving Messages

  1. Check if the pane is alive: tmux list-panes -t genie -a
  2. Check agent state: genie ls — should show idle
  3. Check mailbox for pending messages: look at .genie/mailbox/<agent>.json

Session Not Found

Pane Content Not Captured

If genie read or state detection fails, check:
  • terminal.readLines is sufficient (increase if prompts are far from bottom)
  • The pane ID in the agent registry matches an actual tmux pane
  • tmux server hasn’t been restarted since agents were spawned