tmux

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

tmux Subagent Orchestration

tmux 子代理编排

Run Devin CLI subagents in parallel by giving each one its own tmux window. The parent agent delegates a task, waits for a completion signal, reads the subagent's output file, and closes the window.
通过为每个Devin CLI子代理分配独立的tmux窗口,实现并行运行。父代理委派任务,等待完成信号,读取子代理的输出文件,然后关闭窗口。

When to Use

使用场景

  • Fan out independent research, refactors, or test runs across several agents.
  • Keep a long-running Devin session alive in the background while continuing other work.
  • Coordinate multiple agents that each own a distinct task/context.
  • 将独立的研究、重构或测试任务分发到多个代理并行处理。
  • 在后台保持长时间运行的Devin会话,同时进行其他工作。
  • 协调各自拥有不同任务/上下文的多个代理。

Setup (do once per session)

会话初始化(每个会话执行一次)

Before any tmux operation, resolve two values and reuse them:
  1. TMUX=$(which tmux)
    - absolute path to the tmux binary.
  2. SESSION=$("$TMUX" display-message -p '#S')
    - current session name.
If
TMUX
is unset in the environment, you are not inside a tmux session and the helper scripts will refuse to run. Start tmux first (
tmux new -s work
) and relaunch Devin inside it.
在执行任何tmux操作前,需确定并复用两个值:
  1. TMUX=$(which tmux)
    - tmux二进制文件的绝对路径。
  2. SESSION=$("$TMUX" display-message -p '#S')
    - 当前会话名称。
如果环境中未设置
TMUX
,说明你不在tmux会话内,辅助脚本将无法运行。请先启动tmux(
tmux new -s work
),然后在其中重新启动Devin。

Helper Scripts

辅助脚本

Use these for all standard operations. Run them from this skill directory (
skills/tmux/
). All scripts print
Done
on success or an
error:
line on failure, and exit non-zero on error.
ScriptUsageDescription
scripts/spawn_subagent.sh
<window-name> [command]
Create a new window and start a subagent. Default command:
devin --permission-mode dangerous
scripts/send_command.sh
<window-name> <command>
Send literal text to the window, wait 1s, press Enter
scripts/exit_subagent.sh
<window-name>
Send
/exit
, wait 1s, kill the window if still present
所有标准操作均使用以下脚本。请从该技能目录(
skills/tmux/
)运行脚本。所有脚本在成功时输出
Done
,失败时输出
error:
行,且失败时返回非零退出码。
脚本使用方法描述
scripts/spawn_subagent.sh
<window-name> [command]
创建新窗口并启动子代理。默认命令:
devin --permission-mode dangerous
scripts/send_command.sh
<window-name> <command>
向窗口发送文本,等待1秒后按下回车键
scripts/exit_subagent.sh
<window-name>
发送
/exit
命令,等待1秒后若窗口仍存在则关闭它

Subagent Workflow

子代理工作流

bash
undefined
bash
undefined

1. Spawn (defaults to
devin --permission-mode dangerous
)

1. 生成子代理(默认命令为
devin --permission-mode dangerous

./scripts/spawn_subagent.sh agent-research-1
./scripts/spawn_subagent.sh agent-research-1

2. Send the task. Tell the subagent to write its output to a file

2. 发送任务。告知子代理将输出写入文件

and notify the parent when finished.

并在完成时通知父代理。

./scripts/send_command.sh agent-research-1
"Research X and write the result to /tmp/agent-research-1.md. When done, run: tmux display-message -d 5000 'agent-research-1: done'"
./scripts/send_command.sh agent-research-1
"研究X并将结果写入/tmp/agent-research-1.md。完成后运行:tmux display-message -d 5000 'agent-research-1: done'"

3. Wait for the notification (display-message or agentmail).

3. 等待通知(display-message或agentmail)。

DO NOT poll capture-pane in a loop.

禁止循环轮询capture-pane。

4. Read /tmp/agent-research-1.md

4. 读取/tmp/agent-research-1.md文件

5. Clean up

5. 清理资源

./scripts/exit_subagent.sh agent-research-1
undefined
./scripts/exit_subagent.sh agent-research-1
undefined

Mandatory Requirements

强制要求

  1. Use tmux windows, never panes.
  2. Window names MUST follow
    agent-{task}-{number}
    (e.g.
    agent-refactor-2
    ).
  3. Wait for subagent notifications via
    display-message
    or agentmail. Do not poll
    capture-pane
    in a loop.
  4. Use
    spawn_subagent.sh
    to spawn,
    send_command.sh
    to send input, and
    exit_subagent.sh
    to stop. Fall back to raw
    tmux
    commands only for debugging or edge cases.
  5. Each subagent task MUST write its result to a known file path (e.g.
    /tmp/<window-name>.md
    ). Do not scrape it from the pane.
  1. 使用tmux 窗口,切勿使用窗格。
  2. 窗口名称必须遵循
    agent-{task}-{number}
    格式(例如
    agent-refactor-2
    )。
  3. 通过
    display-message
    或agentmail等待子代理通知。严禁循环轮询
    capture-pane
  4. 使用
    spawn_subagent.sh
    生成子代理,
    send_command.sh
    发送输入,
    exit_subagent.sh
    停止子代理。仅在调试或边缘场景下使用原生
    tmux
    命令。
  5. 每个子代理任务必须将结果写入已知文件路径(例如
    /tmp/<window-name>.md
    )。请勿从窗格中抓取结果。

Completion Signal

完成信号

When a subagent finishes, have it run:
bash
tmux display-message -d 5000 "<window-name>: <short message>"
The parent agent receives the message in its tmux status line and can proceed.
子代理完成任务后,需运行以下命令:
bash
tmux display-message -d 5000 "<window-name>: <short message>"
父代理会在tmux状态栏收到该消息,然后继续后续操作。

Common Subagent Commands

常用子代理命令

Commands to send into a Devin subagent window with
send_command.sh
:
CommandDescription
/exit
Exit the agent gracefully
/clear
Clear the agent's context window
/compact handoff:<info>
Compact context, preserving handoff notes
可使用
send_command.sh
发送到Devin子代理窗口的命令:
命令描述
/exit
优雅退出代理
/clear
清空代理的上下文窗口
/compact handoff:<info>
压缩上下文,保留交接备注

Raw tmux Reference (edge cases only)

原生tmux参考(仅用于边缘场景)

See
references/tmux-commands.md
for the raw
tmux
command cheat sheet used for debugging (listing windows, capturing pane output, sending Ctrl-C, etc.).
调试时使用的原生
tmux
命令速查表请查看
references/tmux-commands.md
(包括列出窗口、捕获窗格输出、发送Ctrl-C等操作)。