Repository navigation
Description
Note
Shipped since filing: 0.64.0 (#727, closing #723) resolved Server.__repr__ socket paths; 0.66.0 (#730, closing #725) raises SocketPathTooLong; 0.68.0 (#902, closing #340) raises TmuxObjectDoesNotExist on closed targets; 0.70.0 suppresses Server.raise_if_dead() output (#641), emits one ERROR record when Server.sessions/clients/attached_sessions swallow a failure (#748), and propagates TmuxCommandTimeout across all list accessors (#807); and sessionless server startup under exit-empty moved to #923. Three items remain open here: (1) error-handling symmetry between Server.sessions/clients and Server.windows/panes, (2) a public error-classification surface over _is_daemon_not_up_error / _is_target_not_found_error, and (3) making EnvironmentMixin raise a LibTmuxException instead of bare ValueError.
Summary
Four server, listing, and environment error-handling gaps remain open from the v0.61.0 downstream MCP audit after #713 and #714 (shipped in v0.62.0) resolved self-location (Server.from_env(), Session.from_env(), Window.from_env(), Pane.from_env() anchored on $TMUX_PANE) and removed the unreachable socket_path derivation in Server.__init__ (Server.__repr__'s hardcoded /tmp fallback is tracked separately in #723).
Defects
Server.start_server() leaves a stale socket under exit-empty
Server.start_server() (src/libtmux/server.py lines 1486–1496) runs tmux start-server without verifying liveness. With exit-empty on (tmux's default), a sessionless server exits immediately: server.is_alive() still returns False, yet a stale socket file remains on disk and survives server.kill(). Socket-file existence cannot test liveness, and start_server() alone neither ensures a running daemon nor tells the caller why nothing stayed up.
Error-handling asymmetry across Server list accessors
Server.sessions (src/libtmux/server.py lines 2400–2420) and Server.clients (src/libtmux/server.py lines 2461–2492) catch every LibTmuxException and return an empty QueryList, making a permission error or overlong socket path (File name too long) indistinguishable from "no sessions". Server.windows (src/libtmux/server.py lines 2423–2439) and Server.panes (src/libtmux/server.py lines 2442–2458) instead delegate to _fetch_or_empty (src/libtmux/server.py lines 65–82), which swallows only daemon-not-up errors via _is_daemon_not_up_error and re-raises other failures. Note that lenient list accessors are deliberate policy (v0.57.0 tried raise-on-error and reverted it in v0.57.1); the defect is the behavioral split between the two accessor pairs, not empty-on-absent-daemon itself.
Private stderr classifiers lack a public error-classification surface
_is_daemon_not_up_error (src/libtmux/server.py lines 52–62) and _is_target_not_found_error (src/libtmux/neo.py lines 779–823, added in #713) classify tmux stderr phrasings (no server running, error connecting to ... (No such file or directory), can't find pane/window/session) privately across two modules. Downstream consumers still have to string-match raw tmux stderr by hand.
EnvironmentMixin raises bare ValueError instead of LibTmuxException
set_environment (src/libtmux/common.py line 115), unset_environment (src/libtmux/common.py line 144), and remove_environment (src/libtmux/common.py line 173) each raise a bare ValueError on tmux stderr, bypassing LibTmuxException. Callers that catch LibTmuxException miss routine set-environment failures such as a dead server.
Invariants
The invariants below are non-negotiable; everything under Intent is open.
Server.sessions,Server.windows,Server.panes, andServer.clientspreserve the emptyQueryListcontract when no tmux server is running on the socket, and share a single consistent rule for non-daemon errors.- Every tmux command failure raised by
EnvironmentMixininherits fromLibTmuxException(subclassingValueErroras well if needed for backward compatibility withexcept ValueError:callers). - Socket paths for
-Lnamed sockets are never guessed in Python without asking tmux (#{socket_path}), preserving the decision recorded in feat(Server,Session,Window,Pane): Resolve the pane you run inside (from_env) #714.
Intent
Non-binding direction:
- Document
exit-emptybehavior onServer.start_server()(or pair it with an opt-in liveness check). - Consolidate
_is_daemon_not_up_errorand_is_target_not_found_errorbehind one error-classification surface rather than accreting per-module string matchers.
References
- Resolved self-location and
Server.__init__dead-code slices (v0.62.0): fix(Pane,Window): Resolve point lookups through tmux #713, feat(Server,Session,Window,Pane): Resolve the pane you run inside (from_env) #714, closed earlier draft Complete the from_env family: know which pane, window, session and server you're running in #705 - Resolved follow-ups:
Server.__repr__hard-codes/tmp/tmux-<euid>/default, ignoring$TMUX_TMPDIR#723 (Server.__repr__socket path, fixed in0.64.0via Resolve the socket path in Server's repr instead of hard-coding /tmp #727),Serverdoes not validate socket path length; overrun surfaces as a raw tmuxFile name too long#725 (SocketPathTooLong, fixed in0.66.0via Measure a tmux socket path where tmux resolves it #730), MissingTmuxObjectDoesNotExistand silent stderr on closed targets #340 (TmuxObjectDoesNotExist, fixed in0.68.0via tmux(fix[errors]): Raise TmuxObjectDoesNotExist for a closed target #902), Server(fix[raise_if_dead]): Suppress check_call output #641 (raise_if_dead()output suppression in0.70.0); sessionless startup tracked in AddServer.connect_or_start()to keep a server up with no sessions #923 - Downstream MCP audit cross-references (
v0.1.0a17againstlibtmuxv0.61.0): libtmux-mcp#92, libtmux-mcp#93, libtmux-mcp#94, libtmux-mcp#95, libtmux-mcp#96
Exact lookup before deleting a registry row
On 6c92651, Server.has_session(name, exact=True) returned False both for an absent name on a responding server and for an unreachable socket. Adding exact=True changes name matching. It does not distinguish those two outcomes. The AWS Labs CLI Agent Orchestrator needs that distinction before deleting a row from its local SQLite registry. Current boolean conversion · Downstream teardown
An opt-in lookup such as has_session_strict(name) could answer from one request to the selected server. Return True for the exact name and False for an authoritative miss, including a responding daemon with no sessions. Raise on an unreachable or denied endpoint, timeout, or malformed reply. A prefix-only match must leave the unrelated session alone. The existing inventory accessors can keep their lenient return contract.
A local adapter exercised the downstream service against temporary SQLite databases and 15 tmux builds. Confirmed misses allowed deletion. Permission denial, a live daemon whose socket path had disappeared, malformed output, and timeout all preserved the row. The matrix ran 91 cases in total. #944 covers the different success result for a checked pane capture.
Activity
tony commentedon Jul 11, 2026
Status update, because this issue's linked PR (#705) is now closed and the live work is elsewhere.
Addressed by #713 + #714 (stacked; #713 →
master, #714 → #713):Server.from_env(),Session.from_env(),Window.from_env()andPane.from_env()land in feat(Server,Session,Window,Pane): Resolve the pane you run inside (from_env) #714, anchored onTMUX_PANE.socket_pathderivation inServer.__init__. Removed in feat(Server,Session,Window,Pane): Resolve the pane you run inside (from_env) #714 — deleted, not repaired. This issue argued repair was better; I disagree, and feat(Server,Session,Window,Pane): Resolve the pane you run inside (from_env) #714 says why: tmux resolves a-Lname against its own socket directory, honouringTMUX_TMPDIR, the per-uid directory and platform overrides, so any path libtmux guesses is a guess. Callers that need the real path ask tmux (#{socket_path}). The consequence is thatsocket_pathstaysNonefor a named socket, which is now pinned by a test.I have not used a closing keyword, deliberately: #714 addresses two of this issue's asks, and the papercuts in §3 are untouched and unowned. Closing this on #714's merge would bury them.
Still open, still true on master, tracked nowhere else:
Server.start_server()has no liveness check.Server.sessions/.clientsswallow everyLibTmuxException, while.panes/.windowsre-raise via_fetch_or_empty. Worth reframing:AGENTS.mddeliberately blesses empty-on-error as the contract for list accessors (raise-on-error shipped in 0.57.0 and was reverted), so the defect is the inconsistency between the two groups, not the leniency itself.neo._is_target_not_found_error), so there are now two — an argument for promoting a single error-classification surface rather than accreting more.common.pyraises three bareValueErrors, not one.Adjacent, and not claimed by this issue:
Server.__repr__still fabricatessocket_path=/tmp/tmux-{euid}/default. #714 deleted the unreachable path guess and left this reachable one, which also ignoresTMUX_TMPDIR. Worth its own issue.Also note §2's benchmark table goes partly stale when #713 merges:
Pane.from_pane_idstops doing alist-panes -aserver-wide scan, so its number drops substantially.Suggest rescoping this to §3 (or splitting 3(a)–(d) out) rather than closing it wholesale.
Resolve the pane you are running inside: from_env() (#714)
[-]No self-location API (TMUX_PANE), and the socket_path derivation in Server.__init__ is unreachable dead code[/-][+]`Server` liveness, list error handling, and `EnvironmentMixin` errors[/+]tony commentedon Nov 24, 2026
The first defect here (
Server.start_server()leaving nothing running underexit-empty on) is now tracked as a feature in #923, which proposesServer.connect_or_start()and shows a one-call start that keeps a sessionless server up. This issue keeps the other three defects. Lifecycle conflicts and ordering are in #925.Server(fix[raise_if_dead]): Suppress check_call output (#641)
tony commentedon Dec 4, 2026
#955 adds
Server.has_session_strict(name)for one exact name. A live daemon with no matching session can confirm absence. Socket denial, disconnection, timeout, and malformed replies keep the outcome uncertain. In the AWS Labs CLI Agent Orchestrator’s local SQLite fixture, strict lookup retained all 60 rows on uncertain reads and removed all 30 confirmed misses. The listing andEnvironmentMixinitems in this issue remain open.