Catalogue / tmux-agent-status-triage
tmux-agent-status-triage
Older skill: source not recordedSignedDebugs broken AI-agent status detection in the tmux statusline plugin tmux-opencode-integrated. Covers listing agent panes, capturing pane text exactly as the detector reads it, reproducing verdicts with the plugin's libtmux-based smart_name helpers, repairing regex patterns on the ERROR, WAITING, B…--- name: tmux-agent-status-triage description: > Debugs broken AI-agent status detection in the tmux statusline plugin tmux-opencode-integrated. Covers listing agent panes, capturing pane text exactly as the detector reads it, reproducing verdicts with the plugin's libtmux-based smart_name helpers, repairing regex patterns on the ERROR, WAITING, BUSY, IDLE, UNKNOWN ladder, then proving the fix with pytest and rebuilding the package with Nix. Use when status icons mislabel agents such as opencode, claude or amp, when detection stops matching after an agent update, or when a new agent needs patterns. Not for sending keystrokes to agents, general tmux administration, or writing a statusline from scratch. ---
tmux agent status triage
The plugin behind these status icons works in a straight line: pick the panes running recognized agents, read the tail of each pane, scrub escape codes, run the text down an ordered set of regexes, show the first verdict that hits. When an icon lies, exactly one link in that chain is broken. Work the links in order — pane selection, captured bytes, cleaning, pattern placement — and let the symptom tell you where to enter.
This skill assumes a local checkout of the plugin: its detection module smart_name.py, its pytest file tests/test_smart_name.py, and its Nix flake output tmux-opencode-integrated. It does not ship or install any of those; if the checkout is missing, stop and ask the user where it lives. The workflow is a reworking of the MIT-licensed tmux-status-debug skill from the edmundmiller/dotfiles repository — keep that credit if you pass this on. Machine-specific absolute paths from the original are replaced by your checkout's real paths.
Route the symptom
| What the user reports | Likely broken link | Enter at | | --- | --- | --- | | Every pane reads UNKNOWN | Capture depth or program filtering | Phases 2 and 3 | | One pane shows ERROR while the agent sits waiting | Stale error text still inside the scanned tail | Phase 2 | | Detection died right after an agent update | The agent reworded its on-screen hints | Phase 4 | | A brand-new agent never gets an icon at all | Its program name is not a recognized agent | Phase 3 |
The ladder you are reproducing
Evaluation runs top to bottom and stops at the first rung whose pattern hits, so a pattern's position is a policy decision, not a formatting detail.
| Rung | State it asserts | Fingerprint examples | | --- | --- | --- | | ERROR | The agent failed | Python traceback header, panic text, FATAL, HTTP 5xx body | | WAITING | Blocked on a human | Permission request, allow-once offer, yes/no/skip question | | BUSY | Working | Interrupt or cancel hint, spinner glyph, running-tools line, progress bar | | IDLE | Resting at a prompt | Version banner, keybinding hints, context or token readout | | UNKNOWN | Nothing matched | Fallback only — never a goal |
WAITING deliberately outranks BUSY: an agent that is mid-task but blocked on permission is, from the user's chair, waiting. ERROR outranks everything because a traceback scrolled just above a prompt still means the run failed.
Phase 1 — Survey which panes are in play
Start here so every later command has real targets:
tmux list-panes -a -F '#{session_name}:#{window_index}.#{pane_index}|#{pane_current_command}'-a reaches every session on the server, and the format string emits a composite target plus the foreground program, pipe-separated so window names with spaces survive. Keep the composite form whole — capture-pane takes it verbatim.
Treat the program column as a lead, not a verdict: a Node-based agent shows up as node, and an agent suspended behind its shell shows zsh while its text is still on screen. When the column and the on-screen text disagree, believe the text and match on both.
Phase 2 — Capture the exact bytes the detector reads
| Flag | Effect | Why it matters | | --- | --- | --- | | -p | Prints to stdout | Without it the capture lands in the paste buffer — a silent change to session state; always pass it | | -S -20 | Starts 20 lines above the pane bottom | This is the detection window; your depth must equal the module's or you test different text than production reads | | -e | Keeps escape sequences in the output | Pass it only if the detector captures with escapes; otherwise your sample is cleaner than reality | | -t target | Picks the pane | Feed it the composite target from Phase 1 |
tmux capture-pane -p -t atlas:2.1 -S -20
Before blaming a regex, look at the raw bytes — spinner redraws plant carriage returns and other control characters between visible words:
tmux capture-pane -p -t atlas:2.1 -S -20 | cat -v | tail -8
A phrase chopped apart by stray ^M bytes is the classic reason a pattern that ought to hit does not. Settle text-versus-regex with a fixed-string count before touching any pattern:
tmux capture-pane -p -t atlas:2.1 -S -20 | grep -F -c 'Apply edit to services/auth/token.go'
A count above zero with a disagreeing verdict points at your regex escaping; a count of zero sends you back to cat -v.
Phase 3 — Reproduce the verdict with the plugin's own helpers
Guessing at the detector from outside is how fixes miss. Import the real module and let it judge:
| Helper | Signature and return | Role | | --- | --- | --- | | get_pane_program | pane in, program-name string out | Resolves the foreground program more smartly than the raw command field | | AGENT_PROGRAMS | Set of recognized program names | Membership here decides whether a pane gets status at all | | strip_ansi_and_control | text in, cleaned text out | Removes the escapes and control bytes before matching | | get_opencode_status | pane in, verdict string out | Runs its own capture plus the whole ladder; this is the icon's source of truth |
Write this sweep to a temp file (say /tmp/verdict_sweep.py). The path insertion must precede the smart_name import — point it at the directory holding smart_name.py in the checkout:
import sys
sys.path.insert(0, "/path/to/checkout/directory-with-smart_name.py")
import libtmux
import smart_name
srv = libtmux.Server()
for sess in srv.sessions:
for win in sess.windows:
for pane in win.panes:
prog = smart_name.get_pane_program(pane)
if prog not in smart_name.AGENT_PROGRAMS:
continue
print(f"\n### {prog} — {sess.name}:{win.name}")
try:
raw = pane.cmd("capture-pane", "-p", "-S", "-20").stdout
body = "\n".join(raw) if isinstance(raw, list) else str(raw)
print(smart_name.strip_ansi_and_control(body)[-300:])
print(f"verdict: {smart_name.get_opencode_status(pane)}")
except Exception as exc:
print(f"capture failed: {exc}")The .stdout of a libtmux command can arrive as a list of lines or a single string, hence the join-or-strapl. When your printed tail and the helper's verdict disagree, you have found a depth or escape-handling mismatch — align your flags with the module's hard-coded ones and rerun.
The system interpreter lacks libtmux, so run the sweep with the Python the package was built with. A No module named libtmux error always means you grabbed the wrong interpreter. Build the package, print its store path, and read the interpreter out of the wrapper's first lines:
nix build .#tmux-opencode-integrated --no-link --print-out-paths head -10 /nix/store/<hash>-tmux-opencode-integrated-*/share/tmux-plugins/tmux-opencode-integrated/scripts/smart-name.sh
Then invoke the sweep with the Python path that wrapper records. For a never-detected new agent, extend AGENT_PROGRAMS with its program name before anything else — no pattern can fire on a pane the filter skips.
Phase 4 — Repair or add a pattern
- Freeze ground truth first. Have the user hold the agent in a named state and save the cleaned capture from Phase 3 to a file at once; the screen changes under you, and you cannot design against a moving target.
- Choose a literal phrase unique to that state, and reason about its lifetime: a cancel hint exists only while work runs, so it proves BUSY; a version banner survives the whole session, so it can only ever prove IDLE. Reject spinners, counters and timestamps — they change every frame.
- Add the pattern to the matching rung's list inside
smart_name.py, from the frozen capture, never from memory. - Check it in isolation against the frozen sample before touching the plugin:
import re
sample = "ctrl+t tabs ctrl+p palette Opencode 1.2.7"
checks = [(r"Opencode \d+\.\d+\.\d+", "IDLE banner"),
(r"ctrl\+p palette", "IDLE hints"),
(r"esc to stop", "BUSY stop hint")]
for pat, why in checks:
print("hit " if re.search(pat, sample, re.I) else "miss", why, pat)- Say out loud why the pattern belongs on its rung — remember, unescaped
+,.or(will quietly turn a hit into a miss.
Phase 5 — Land the change
A pattern that only you have seen is unproven. Add a case to tests/test_smart_name.py asserting the new pattern maps to its rung, then run the suite from the checkout root — the project invokes it as uvx pytest tests/test_smart_name.py -v, and a plain pytest works equally well if it is already installed. Rebuild so the running plugin picks up the change:
nix build .#tmux-opencode-integrated
This leaves a result symlink in the checkout; nothing is published. Close the loop by rerunning the Phase 3 sweep and confirming the icon now agrees with what the agent is actually doing. If the change will be committed or pushed anywhere beyond this machine, get the user's explicit go-ahead first.
Fault table
| Observation | Probable cause | Remedy | | --- | --- | --- | | All panes UNKNOWN | Your depth or escape flags differ from the module's | Match its hard-coded flags, rerun the sweep | | ERROR while the agent idles | Old traceback inside the last 20 lines | Tighten the pattern or require error text nearer the bottom | | BUSY never fires during work | An update reworded the hint | Rebuild the pattern from a live frozen capture | | Program column shows a shell | The shell owns the pane; the agent is its child | Rely on get_pane_program and content fingerprints | | Fixed string hits, regex misses | Unescaped metacharacters | Escape them or test that pattern as a fixed string | | Import error for libtmux | Wrong interpreter | Use the Python named in the package wrapper |
Guardrails
Everything here observes; it must not act. You must not type into, or otherwise inject input to, a live agent pane to force a state onto the screen — that can execute commands as the user. Ask the user to produce the state instead; if interaction ever becomes unavoidable, name exactly what would be typed and wait for explicit approval. Do not kill, resize, detach or rearrange panes hunting for a cleaner repaint — capture what is there. Keep captures read-only by always printing to stdout rather than filling the paste buffer. Pane contents routinely hold tokens, keys and private paths: redact secrets before quoting a capture anywhere, and never paste raw captures into shared channels or reports.
| File | Size | SHA-256 |
|---|---|---|
| SKILL.md | 11.4 kB | 6ce8472d6dd5 |
| THIRD_PARTY_NOTICES.md | 1.4 kB | b47407ebaef3 |
| examples.json | 1.9 kB | feb14fb9df33 |
Published verbatim from the pinned commit. Nothing is rewritten.
| Version | Pinned commit | Signed | |
|---|---|---|---|
| 1.0.0 Current | Not recorded | 10 Oct 2026 |
Locking a skill to one version needs Pro.