2026.09.01
herdrでマルチエージェント運用を実践する方法:役割分担からエージェント間連携まで
はじめに
こんにちは。次世代ベトナム研究室のK.X.Dです。
Claude Codeで設計を詰め、Codexに実装を任せ、別のエージェントにテストを監視させる——複数のAIコーディングエージェントを同時に動かす開発スタイルは、もう珍しいものではありません。実際、JetBrainsが2026年8月に公開した調査では、プロフェッショナル開発者の90%が少なくとも週1回はAIコーディングエージェントを業務で使用しており、68%は毎日使用していると回答しています(JetBrains, Developer Ecosystem Survey 2026)。問題はエージェントを「動かすこと」自体ではなく、役割をどう分担し、誰がブロックされているかをどう把握し、エージェント同士をどう連携させるか、という運用の部分です。
本記事では、herdr(ハーダー)というRust製ターミナルマルチプレクサを使って、この運用を実際にどう組み立てるかを解説します。herdr公式ドキュメントに載っている具体的なコマンドとレシピを実際に確認しながら、役割分担型のワークスペース構築、エージェント間の自動連携、状態トリアージ、リモートでの長時間運用まで、手を動かして検証した内容をお届けします。
AIコーディングエージェントを同時に何本も動かすとき、本当に難しいのはエージェントを起動することではなく、状態を把握し、連携させることです。本ガイドでは、オープンソースのherdrを使って、その運用を実際にどう組み立てるかを、公式ドキュメントのコマンドに沿って解説します。
この記事の要点
- herdrは「ワークスペース→タブ→ペイン」という単位でエージェントの居場所を整理し、各ペインの状態を「working(作業中)」「blocked(入力待ち)」「done(完了・未確認)」「idle(待機中)」「unknown(不明)」の5段階でサイドバーに表示します。
herdr pane splitやherdr agent start --kindといったCLIコマンドで、1つのワークスペース内に役割の異なる複数エージェントを立ち上げられますherdr agent prompt --waitとherdr agent wait --until blockedを組み合わせると、あるエージェント(オーケストレーター役)が別のエージェント(ワーカー役)の作業完了やブロックを検知して次の指示を出せます。- すべてのエージェントが同じ精度で状態検知されるわけではありません。ライフサイクルフックに対応したエージェントの方が、マルチエージェント自動化の土台として信頼性が高くなります。
- herdrは2026年3月27日にGitHubへ公開されたばかりのオープンソース(Apache License 2.0)で、2026年8月29日時点で3万3,198のスターを獲得しています。
1. なぜ複数のAIコーディングエージェントの運用は難しいのか
アーキテクチャ設計にClaude Codeを、実装にCodexを、細かな修正にGitHub Copilot CLIを、というように複数のエージェントを目的別に並行稼働させると、「どのペインが今どんな状態か」「誰が人間の判断を待っているのか」を人間が逐一確認する負荷が増えます。さらに一歩進んで「あるエージェントに別のエージェントの完了を待たせて、自動的に次の指示を出させる」ところまでやろうとすると、単なるターミナル分割では足りません。herdrはこの2つの課題——状態の可視化と、エージェント同士の連携——にそれぞれ具体的な仕組みを持っています。
2. herdrの基本単位を30秒で押さえる
herdr.dev公式ドキュメントによれば、herdrは作業を次の単位で整理します。
- ワークスペース(Workspace):最上位のコンテナ。通常は1つのリポジトリやプロジェクトに対して1つ作ります。サイドバーの状態は、そのワークスペース内にいる全エージェントの状態を集約して表示します。
- タブ(Tab):ワークスペース内のレイアウト。エージェント、ログ、サーバーなど用途ごとにビューを整理できます。
- ペイン(Pane):実際のターミナル。クライアントが切断されても状態を保持し続けます。
- セッション(Session):名前付きの独立した実行環境。
workやside-projectのように複数持てば、それぞれ完全に分離されたペインと永続状態を持ちます。
エージェントの状態は「working」「blocked」「done」「idle」「unknown」の5段階で分類されます。特に実践面で重要なのは、idleとdoneの違いです。herdr公式ドキュメントによれば、doneはバックグラウンド作業が終わった直後でまだそのタブが見られていない状態、idleは同じ状態でもすでにフォーカスされて確認済みの状態を指します。つまりdoneのまま残っているペインは、文字通り「見落とされているエージェント」です。

3. 実践1:役割分担型のワークスペースを組む

複数エージェントの一番シンプルな実践は、1つのワークスペースの中に役割の異なるペインを並べることです。herdr公式ドキュメントは、次のようなコマンド例を示しています。
created=$(herdr workspace create --cwd ~/project --label api --no-focus) pane_id=$(printf '%s\n' "$created" | jq -r '.result.root_pane.pane_id')
split=$(herdr pane split "$pane_id" --direction right --no-focus) review_pane=$(printf '%s\n' "$split" | jq -r '.result.pane.pane_id')
ポイントは、workspace createやpane splitが返すJSONから実際のペインIDを取得して使うことです。ペインIDを推測せず、レスポンスから拾う設計になっています。ペインが用意できたら、そこに実際のエージェントを起動します。
herdr agent start reviewer --kind codex --pane "$review_pane" -- -m gpt-5.4
--kindにはpi、claude、codex、gemini、cursor、devin、cline、opencode、copilot、grokなど、対応する各エージェントの実行コマンドを指定します(サポートされる--kindの全リストはherdr公式ドキュメントで随時更新されています)。agent startはペインの中に既に開いているシェルに対して実行するコマンドで、レイアウト自体は作りません——レイアウトを作るのはworkspace createやpane splitの役目、というように役割が分かれています。名前(reviewerなど)を付けておけば、後からherdr agent getやherdr agent renameでペインIDの代わりに名前で操作できます。
4. 実践2:エージェントに他のエージェントを操作させる

herdrが単なるターミナルマルチプレクサと違うのは、この先です。あるエージェント(あるいはスクリプト)が、別のエージェントにプロンプトを送り、その完了やブロックを検知して次の指示を出せます。herdr公式ドキュメントの「Recipes」セクションが示す典型例はこうです。
split=$(herdr pane split --current --direction right --no-focus) review_pane=$(printf '%s\n' "$split" | jq -r '.result.pane.pane_id') herdr agent start reviewer --kind codex --pane "$review_pane" -- -m gpt-5.4 herdr agent prompt reviewer "Review the current diff" --wait --timeout 120000 herdr agent read reviewer --source recent-unwrapped --lines 120
agent prompt --waitは即座にプロンプトを送信し、エージェントが動き出したことを5秒以内に確認できなければagent_prompt_stalledを返します。動き出したことが確認できれば、指定した状態(デフォルトはidle・done・blockedのいずれか)に落ち着くまで待ちます。つまり、ログファイルをポーリングするような不安定な仕組みではなく、herdrサーバー自身が状態変化を監視して呼び出し元に返す設計です。
エージェントが人間の判断を求めて止まった場合は、待ってから中身を読み、必要な操作を送り返します。
herdr agent wait reviewer --until blocked --timeout 120000 herdr agent read reviewer --source recent-unwrapped --lines 80 herdr agent send-keys reviewer esc
この2つのレシピを組み合わせると、「オーケストレーター役のエージェントが、ワーカー役のエージェントを立ち上げてタスクを渡し、完了かブロックを検知して次の手を打つ」という自動化の骨格が組めます。これは単純なポーリングではなく、herdrサーバーがペインの占有者をピン留めした上でイベント駆動で状態変化を通知する仕組みのため、待っている間に別のプロセスがそのペインを乗っ取っても待機が誤って成立することはありません。
5. 実践3:状態トリアージでブロックを見逃さない運用

エージェントを増やすほど、「誰かが止まっている」ことに気づくのが遅れるリスクも増えます。herdrのサイドバーは全エージェントの状態を集約表示しますが、実践としては次のような優先順位で確認するとよいでしょう。
- まず
blockedのエージェントを最優先で見る——人間の判断を待っている状態であり、放置時間がそのまま手戻りにつながります。 - 次に
doneのエージェントを見る——作業自体は終わっているが、まだ結果を確認していない状態。ここに気づかないと、せっかく終わった作業が放置されます。 workingは基本的に待つだけでよいですが、想定より長くworkingのままであれば、フリーズしている可能性を疑います。unknownは要注意で、herdrが状態を確信を持って分類できていない状態です。herdr公式ドキュメントも「unknownは作業が正常に完了したことを証明するものではない」と明記しており、目視での確認が必要になります。
この優先順位は、スクリプトからも同じ考え方で実装できます。herdr agent wait <name> --until blocked --until doneのように--untilを複数回指定すれば、どちらかの状態になった時点で待機が解除されます。人間が画面を見て判断する代わりに、この待機自体をオーケストレーター側のロジックに組み込めます。
6. 実践4:リモートサーバーでの長時間マルチエージェント運用
herdrはバックグラウンドサーバーとして動作し続けるため、複数エージェントを長時間並走させる運用にも向いています。ノートPCの蓋を閉じても、ネットワークが切れても、マシンを再起動しても、エージェントは動き続け、セッションは元通り復元されます。リモートサーバーにSSHで接続してherdrを起動しておけば、接続を切断してもエージェントの作業は継続し、後からherdrコマンドで同じセッションに再接続できます。
長時間バッチの実践では、以下の組み合わせが有効です。
- 名前付きセッション(
work、nightly-batchなど)でワークスペースを分離し、日中の作業と長時間バッチを混在させない。 - オーケストレーター役のエージェントには、タイムアウトを長めに設定した
agent waitを使わせ、ワーカーが数時間かかる処理を待たせる。 - 定期的に
herdr agent read <name> --source recent-unwrapped --lines 120のような読み取りコマンドで進捗をログとして保存しておくと、後から状態を追いやすい。
7. マルチエージェント運用に向いているエージェントの選び方
自動化の信頼性は、エージェントの状態がどれだけ正確に検知できるかに直結します。herdr.dev公式ドキュメントは、対応エージェントを統合の深さによって明確に3つのティアに分けています。
| 統合ティア | 対応数 | 代表的なエージェント |
|---|---|---|
| ライフサイクルフック統合 | 6種 | Pi、OMP、Kimi Code CLI、MastraCode、OpenCode、Kilo Code CLI |
| スクリーンマニフェスト検出 | 11種 | Claude Code、Codex、Cursor Agent CLI、GitHub Copilot CLI など |
| 実験的サポート/統合限定 | 合計5種 | Gemini CLI、Cline、Amp、Kiro CLI、Maki など |
ライフサイクルフック統合はエージェント側がherdrに直接状態を報告する仕組みを持つため、agent waitやagent prompt --waitの判定が最も安定します。スクリーンマニフェスト検出は専用フックがなく、herdrが画面出力を解析して状態を推定するため、フック統合ほどの確実性はありません。
実践上の指針としては、オーケストレーター側から--until blockedのような正確な状態判定に依存するワーカーには、できるだけライフサイクルフック統合のエージェントを選ぶとよいでしょう。スクリーンマニフェスト検出のエージェントを使う場合は、状態判定の揺れを見込んで待機のタイムアウトを長めに設定し、unknownが返った場合の人間による確認フローを残しておくのが安全です。
8. 実践でよくつまずくポイント
- エージェント起動前にペインをシェルのプロンプトに戻し忘れる:
agent startはシェルが対話プロンプトにある状態のペインを前提にしています。前のコマンドやエディタが残ったままだと起動が失敗します。 - エージェント名の衝突:名前は生きているエージェントの中で一意である必要があり、規則は
[a-z][a-z0-9_-]{0,31}。同じ名前を別のワーカーに使い回すと解決に失敗します。 - 待機中にペインを移動する:
pane moveでワークスペースをまたいでペインを移動すると、その時点で進行中のwaitはagent_not_runningで終了します。待機を張ったまま構成変更をしない方が安全です。 unknown状態を完了扱いしてしまう:unknownはherdrが確信を持てない状態であり、成功を意味しません。オーケストレーターのロジックには、必ず人間によるフォールバック確認を残してください。
9. herdrのインストール
herdrはApache License 2.0で公開されており、無料で利用できます。インストール方法は公式GitHubリポジトリのREADME(2026年8月29日取得)によると次の通りです。
curl -fsSL https://herdr.dev/install.sh | sh
Homebrewやmiseを使っている場合は、以下でも導入できます。
brew install herdr # または mise use -g herdr
Windowsの場合は次のPowerShellコマンドを使います。
powershell -ExecutionPolicy Bypass -c "irm https://herdr.dev/install.ps1 | iex"
10. herdr公式スキルでエージェント自身に運用させる
herdrはCLIだけでなく、コーディングエージェント自身がSKILL.md形式で読み込んで使う公式スキルファイルも同梱しています(herdrdev/herdrリポジトリのskills/herdr/SKILL.md、2026年8月30日取得)。フロントマターのdescriptionには次のように書かれています。
「Control Herdr, a terminal multiplexer for coding agents. Use only when the user explicitly mentions Herdr or asks to use Herdr to inspect or control panes, tabs, workspaces, commands, or another agent. Do not use merely because a task could benefit from a background terminal, delegation, or parallel work. Requires HERDR_ENV=1.」
つまりこのスキルは、「バックグラウンド処理に便利そうだから」という理由だけでは発動せず、ユーザーが明示的にherdrに言及したとき、かつHERDR_ENV=1という環境変数——実際にherdrが管理するペインの中で動いているときだけ——に限って有効化されるよう設計されています。スキル本文は、本記事の実践1・実践2で使ったのとまったく同じコマンド(pane split→agent start→agent prompt --wait→agent wait --until blocked→agent read)を、エージェント自身が安全に使うための手順として説明しており、次のような安全ルールも明記しています。
- 作成していないワークスペース・タブ・ペイン・セッションを勝手に閉じない。
herdr server stopでサーバーを止めたり、herdr本体のプロセスを殺したりしない。- バックグラウンド作業には
--no-focusを使い、ユーザーの操作対象を奪わない。 - IDはJSONレスポンスから取得し、サイドバーの並び順や例から推測しない。

11. 実践1・実践2をスキル化する
実践1(役割分担型のワークスペース)と実践2(オーケストレーター/ワーカー)は、毎回コマンドを手で組み立てるのではなく、1つの再利用可能なスキルとしてパターン化しておくと、エージェント制御の手順が安定します。この2つの実践だけをまとめたherdr-multiagent-practiceという補助スキルを作成しました。
スキルのフロントマターは次の通りです。
--- name: herdr-multiagent-practice description: "Set up a role-based multi-agent workspace in Herdr (one pane per role) and, when asked, have one agent orchestrate another through Herdr. Use only when the user explicitly asks to run multiple agents in Herdr or to have this agent control another agent via Herdr. Requires HERDR_ENV=1." ---
中身は大きく2つの手順に分かれています。
- 実践1(役割分担):ペインを分割し、役割ごとに名前付きエージェントを起動し、前述の初回信頼ダイアログを検出・処理してから、それぞれに独立したタスクを送る。
- 実践2(オーケストレーション):ワーカーを1つ起動し、
agent prompt --waitでタスクを渡し、blockedになった場合はagent wait --until blockedとagent send-keysで対応し、最後にagent readで結果を読み取って使う。
~/.claude/skills/herdr-multiagent-practice/SKILL.mdに配置すれば、対応するエージェントが「herdrで複数エージェントを動かして」といった依頼を受けたときに、このパターンをそのまま呼び出せるようになります。herdr公式のherdrスキルが「安全にCLIを使う一般的な作法」を教えるのに対し、このスキルは「実践1・実践2という具体的な2つの型」に絞り込んだ補助スキルという位置づけです。
---
name: herdr-multiagent-practice
description: "Set up a role-based multi-agent workspace in Herdr (one pane per role, e.g. architect/implementer/reviewer) and, when asked, have one agent orchestrate another through Herdr (spawn a named worker, prompt it, wait for blocked/done, read the result). Use only when the user explicitly asks to run multiple agents in Herdr or to have this agent control another agent via Herdr. Requires HERDR_ENV=1. Companion to Herdr's own official `herdr` skill (skills/herdr/SKILL.md in herdrdev/herdr) — that skill teaches the raw CLI; this skill teaches the two specific practices below."
---
# herdr-multiagent-practice
This skill packages two practices into a repeatable procedure: **role-split** (実践1) and **orchestrate a worker** (実践2). Both assume this agent is already running inside a Herdr-managed pane.
```bash
test "${HERDR_ENV:-}" = 1
```
If that check fails, say you are not running inside Herdr and stop.
## Practice 1: role-split workspace
Use this when the user wants several agents each doing a distinct, independent job (e.g. one drafts a design, another implements, a third reviews) without needing them to talk to each other.
1. Reuse the current workspace unless the user asks for a new one:
```bash
herdr pane split --current --direction right --cwd "$PWD" --no-focus
```
Read the new pane ID from `.result.pane.pane_id`. **A pane returned from `split` is not always immediately available** — `agent start` can fail with `agent_pane_busy` for a second or two right after the split. Retry once after a short pause rather than treating the first failure as fatal.
2. Start a named, role-labeled agent in each pane:
```bash
herdr agent start architect --kind claude --pane <pane-id-1> --timeout 60000
herdr agent start implementer --kind codex --pane <pane-id-2> --timeout 60000
```
3. **First run in a brand-new directory shows a one-time trust dialog**, not the normal chat prompt. Both Claude Code and Codex show this. Sending a task prompt into it does nothing useful — Claude Code's dialog defaults to "No, exit" and a plain `agent prompt` can dismiss the agent entirely instead of reaching it. Check for this before prompting:
```bash
herdr agent read <name> --source recent-unwrapped --lines 20
```
If it shows a trust/permission dialog, navigate it explicitly, e.g. for Claude Code:
```bash
herdr agent send-keys <name> down # moves off the default "No, exit" onto "Yes, I trust this folder" and confirms
```
For Codex's directory-trust prompt, option 1 ("Yes, continue") is already selected, so a plain `enter` confirms it. A Codex version-update banner can appear the same way on a later run in the same trusted directory — treat it the same: read first, then send the keys for "Skip" rather than assuming the pane is at its normal prompt.
4. Once each pane is confirmed idle at its real prompt, send each role its own independent task:
```bash
herdr agent prompt architect "<design-only task, e.g. write a short design note>" --wait --timeout 120000
herdr agent prompt implementer "<implementation task>" --wait --timeout 120000
```
5. Report each agent's final `agent_status` and read back its output for the user:
```bash
herdr agent read architect --source recent-unwrapped --lines 60
herdr agent read implementer --source recent-unwrapped --lines 60
```
## Practice 2: orchestrate a worker
Use this when the user wants this agent itself to hand off a sub-task to another agent and act on the result — the pattern behind "have an agent operate another agent."
1. Split a sibling pane and start a named worker (`reviewer` is a good default name for a review task):
```bash
herdr pane split --current --direction right --cwd "$PWD" --no-focus
herdr agent start reviewer --kind codex --pane <pane-id> --timeout 60000
```
2. Confirm the worker is idle (handle any trust/update dialog as in Practice 1), then hand off the task and wait for it to settle:
```bash
herdr agent prompt reviewer "Review the current diff and report only actionable findings." --wait --timeout 120000
```
3. If the worker needs a decision instead of settling normally, it will report `blocked` rather than `idle`/`done`. Wait for that specifically when you expect an approval or question:
```bash
herdr agent wait reviewer --until blocked --timeout 120000
herdr agent read reviewer --source recent-unwrapped --lines 80
herdr agent send-keys reviewer esc # or the appropriate key for the dialog shown
```
4. Read the worker's actual output and use it — do not just report that the command succeeded:
```bash
herdr agent read reviewer --source recent-unwrapped --lines 60
```
## Safety rules (same as Herdr's own `herdr` skill)
- Use `--no-focus` for background work; don't steal the user's focus.
- Use `--current`, an explicit pane ID, or a unique agent name — never guess IDs from examples or sidebar order.
- Never close a workspace, tab, pane, or session you did not create.
- Never run `herdr server stop` or kill the main Herdr process.
- Parse every ID from the JSON response of the command that created it.
12. まとめ
複数のAIコーディングエージェントを運用する上での本当の課題は、「動かすこと」ではなく「役割分担・状態把握・連携」の3点です。herdrは、ワークスペース/ペインという単位でエージェントの居場所を整理し、working/blocked/done/idle/unknownという状態で可視化した上で、agent prompt --waitとagent wait --untilという具体的なコマンドでエージェント同士の連携までカバーしています。まずは役割分担型のワークスペースを1つ組んでみて、オーケストレーター/ワーカーのレシピを実際に動かしてみるところから始めてみてください。
出典
出典(取得日:2026-08-29)
- herdr.dev, Agent automation(v0.8.2)
- herdr.dev, Supported Agents
- herdr.dev, Concepts
- GitHub, herdrdev/herdr リポジトリおよび GitHub API メトリクス
- JetBrains, Developer Ecosystem Survey 2026, 2026年8月
最後に
グループ研究開発本部 次世代システム研究室では、最新のテクノロジーを調査・検証しながらインターネット上の高度なアプリケーション開発を行うエンジニア・アーキテクトを募集しています。募集職種一覧からご応募をお待ちしています。
グループ研究開発本部の最新情報をTwitterで配信中です。ぜひフォローください。
Follow @GMO_RD


