Skip to content

Agent Monitoring

pertmux detects and monitors AI coding agent instances running in tmux panes across all your sessions.

pertmux supports two coding agents:

  • opencode — must be started with --port 0 so pertmux can query its local HTTP server. Status is detected via HTTP API.
  • Claude Code — requires no special flags. Status is detected by reading JSONL transcript files from ~/.claude/.

See Agent Configuration for setup details.

The architecture is pluggable — new agents can be added by implementing the CodingAgent trait. See Extending pertmux and Contributing.

Every 2 seconds (configurable via refresh_interval), the daemon:

  1. Lists all tmux panes across all sessions
  2. Checks each pane’s running process against registered agent process names (opencode, claude)
  3. For matched panes, queries the agent for status using its own mechanism:
    • opencode: Discovers the HTTP server port via process tree inspection and queries the API
    • Claude Code: Reads JSONL transcript files from ~/.claude/ and infers status from the last entry
  4. Enriches each pane with session details (title, model, tokens, messages)
  5. Links each agent pane to its corresponding MR via the worktree path

Each detected agent shows a status badge:

StatusMeaning
BusyAgent is actively working (generating code, running tools)
IdleAgent has finished its current task
RetryAgent encountered an error and is retrying
UnknownStatus could not be determined

Status priority for display: Busy > Retry > Idle > Unknown.

Press a on a worktree with an active agent session to send commands to the agent — rebase, fix pipeline failures, and more. Actions are delivered via HTTP API for opencode and via tmux send-keys for Claude Code. See Agent Actions for details.

When you select an agent pane, the detail panel shows:

  • Working directory
  • Token usage (input and output tokens)
  • Message count and session duration
  • File changes (files modified, additions, deletions)
  • Todo list with completion status
  • Message timeline with role indicators and text previews

If you don’t configure any forge ([gitlab] or [github]), pertmux runs in agent-only mode — showing a simple list of all detected coding agents grouped by tmux session.