Respawn pane

respawn_pane

respawn_pane
mutating tool
mutating tool
respawn_pane

Restart a pane’s process in place, preserving pane_id and layout.

Returns:

PaneInfo

Use when a pane’s shell or command has wedged (hung REPL, runaway process, bad terminal mode) and you need a clean restart without destroying the pane_id references other tools or callers may still be holding. With kill=True (the default) tmux kills the current process first; optional shell relaunches with a different command; optional start_directory sets its cwd; optional environment adds per-process env vars (one -e KEY=VALUE flag per entry).

Avoid when the pane genuinely needs to go away — use kill_pane instead. Also avoid when you want to change the layout: respawn-pane preserves the pane in place.

Side effects: Kills the current process (with kill=True) and starts a new one. The pane_id is preserved — that’s the whole point of the tool. pane_pid updates to the new process.

suppress_persistent_history defaults to false for MCP and direct Python calls. It does not inherit LIBTMUX_SUPPRESS_HISTORY. Leave it false to add no history controls for this call. That choice cannot remove inherited, session, or startup-file controls.

Set it to true and respawn_pane copies and merges best-effort no-disk history controls for only the spawned process. It does not change the tmux session environment or affect later panes. The shell can retain in-memory history, and a startup file can override these controls after the process starts.

When you enable it, tmux environment arguments are added, but the spawned process command text is not prefixed or rewritten. The shell text is passed through unchanged. If you also pass environment, any history-control values must agree with the policy. A conflict fails the call, names the variable without including the conflicting value, and is never retried without suppression. See History suppression for shell behavior and Safety tiers for output, scrollback, process, transcript, hook, and logging boundaries.

Tip: Call get_pane_info first if you need to capture pane_current_command before respawn — the new process loses its argv. Omitting shell makes tmux replay the original argv (good default for shells; may differ for processes spawned via custom shell at split time).

Example — recover a wedged pane, relaunching the default shell:

{
  "tool": "respawn_pane",
  "arguments": {
    "pane_id": "%5"
  }
}

Example — relaunch with a different command and working directory:

{
  "tool": "respawn_pane",
  "arguments": {
    "pane_id": "%5",
    "shell": "pytest -x",
    "start_directory": "/home/user/project"
  }
}

Example — relaunch with extra environment variables:

{
  "tool": "respawn_pane",
  "arguments": {
    "pane_id": "%5",
    "shell": "pytest -x",
    "environment": {
      "PYTHONPATH": "/home/user/project/src",
      "DATABASE_URL": "postgres://localhost/test"
    }
  }
}

Mapping input keeps the keys visible in the audit log but replaces each environment value with a {len, sha256_prefix} digest. A JSON object string is redacted as one scalar digest, so its keys are not retained in the audit record. Values may still appear briefly in the OS process table while tmux spawns the new process — see Safety tiers for details.

Response (PaneInfo):

{
  "pane_id": "%5",
  "pane_pid": "98765",
  "pane_current_command": "pytest",
  "pane_current_path": "/home/user/project",
  // ...
}

Parameters

Parameter

Type

Required

Default

Description

pane_id

str

yes

Pane ID (e.g. ‘%1’). Required.

kill

bool

no

True

When True (default), pass -k to tmux so the current process is killed before respawning. When False, respawn fails if the pane already has a running process.

shell

str

no

Replacement command for tmux to launch. When omitted, tmux replays the original argv (good default for shells; may differ for processes spawned via custom shell at split time). Matches the shell parameter on :func:split_window and the eventual upstream Pane.respawn(shell=) API.

start_directory

str

no

Working directory for the relaunched command (maps to respawn-pane -c).

environment

dict[str, str] | str

no

Environment variables to set for the relaunched process. Each item becomes one -e KEY=VALUE flag (tmux’s cmd-respawn-pane.c supports the flag repeatedly). Values supplied in a mapping are redacted in the audit log on a per-key basis — keys like DATABASE_URL remain visible but their values are replaced by {len, sha256_prefix} digests. A JSON object string is redacted as one scalar digest, so its keys are not retained in the audit record. Values may still appear briefly in the OS process table while tmux spawns the new process; do not pass long-lived secrets here when a host-resident agent or other tenant could observe ps.

socket_name

str

no

tmux socket name.

suppress_persistent_history

bool

no

False

Whether to suppress persistent history for the spawned shell. Defaults to False for MCP and direct Python calls. This per-call option does not inherit LIBTMUX_SUPPRESS_HISTORY. Startup files may override these controls.