記事一覧へ
エンジニアはかつてIDEについて議論し、今はハーネスについて議論する。
私はオープンソースのハーネス(Roo Code、DeepAgent CLI、HumanLayer)を使い、貢献してきた。初日に知っておきたかったことがある:ハーネスの出力をスラッジと直交させるために今すぐできることが3つある。それでも3つすべてに人間の判断が必要だ。
このガイドは、ハーネスが出力を複利にするか間違いを複利にするかを分ける単純なサーフェスをカバーする:設定ファイルを推論可能なほど軽く保つ方法、R.P.Iフレームワークを使ってモデルがスタッフエンジニアのように問題に向き合うプロンプトを構造化する方法、サブエージェントを使ってメインコンテキストウィンドウをクリーンに保つ方法。
最後には、今日のセットアップにできる具体的な変更のセットと、ハーネス(モデルだけでなく)こそがあなたのエンジニアリングの判断が違いを生む場所だという明確な感覚が得られるはずだ。
モデルが知能の源なら、ハーネスはその知能を有用にするものだ。ハーネスの主な仕事は以下を行う足場として機能することだ:
・セッションと圧縮によって本質的にステートレスなLLMのコンテキストを管理する
・ツール呼び出し、I/O処理、ガードレールをモデル周囲で動作させる
ハーネスを `while (have next message) do {tool}` ループと考えよう。滑らかなハーネス1つが以降に生成されるすべてのコードのスピードと品質を増幅する。
■ .mdファイルを軽く、人間が書いたものにする
今日のエージェントの核心的な欠点は「インストラクションバジェット」の概念だ。HumanLayerのKyleのパラフレーズで言うと、フロンティアの思考LLMはブロート(肥大化)の中で関連する指示に注意を払えなくなる「ダムゾーン」に入る前に数百の指示しか従えない。指示が多すぎると、実質的にモデルに幻覚を起こすよう促している。
グローバルシステムプロンプト——CLAUDE.mdやAGENTS.md——では、人間が書いたものがLLMが生成したものを上回る。ETHの研究はLLM生成のシステムプロンプトがパフォーマンスを低下させ、推論コストが約20%増加することを発見した。最小限の要件を記述する:プロジェクトが何か、エンドユーザーは誰か。すべてのトークンは場所を争うべきだ——毎回のセッションでグローバルに注入されるから。
モデルが必要とするかもしれないすべてをフロントロードし、できる限り詳細なif-elseルールを規定したいという衝動がある。しかしコンテキストを直接解析することはコンテキストウィンドウの貴重なスペースを消費し、推論ウィンドウをドロップさせる。
代わりに、プログレッシブ・ディスクロージャーを適用する:エージェントが必要な時だけコンテキストを引き出すようにし、個々の.mdファイルに説明的な名前を付けることで何が存在するかを知らせる。
【CLIs(コマンドラインインターフェース)】
エンジニアはすでにCLIでプログレッシブ・ディスクロージャーを名前もつけずに使っている。利用可能なサブコマンドを見るために--helpを実行し、特定のサブコマンドの--helpを掘り下げてフラグを確認する。エージェントも同じことができる。これはモデルが見たことのないCLI——あなたのAPIをラップするカスタム内部ツールでトレーニングデータがゼロ——で最も重要だ。プログレッシブ・ディスクロージャーなしでは、全リファレンスをコンテキストに貼り付ける必要があるだろう。これがあれば、エージェントはmycli --helpを実行し、関連サブコマンドを見つけ、次にmycli deploy --helpで特定のフラグを取得する。モデルはあなたがするのと同じ方法でツールのコマンドを発見し、コンテキストはクリーンなままだ。
【Skills(スキル)】
ここで業界が収束している。Claude Code、Codex、OpenCodeはすべて同じ方法でスキルのプログレッシブ・ディスクロージャーを実装している:起動時に、各スキルの名前と説明のみがコンテキストに読み込まれる。完全なSKILL.md指示はエージェントが現在のタスクにスキルが関連すると判断した時のみ読まれる。スキルは必要に応じてのみ読み込まれる参照ファイルやスクリプトを指すことができる。明確で具体的な説明を書けば、エージェントはボディを読まずにそれにマッチできる。エンジニアとして、これは具体的に、エージェントがリクエストに基づいて取得できる明確な命名規則を持つ個別ファイルに特定の指示(スキル)をコードベース全体にわたって維持することが有用だということを意味する。
【MCP tools(MCPツール)】
これはハーネスが大きく分岐する場所だ。
Claude CodeはビルトインのMCPツール検索を搭載している:セッション開始時にツール名の軽量インデックスを読み込み、次にオンデマンドで完全なスキーマを検索・取得する——Anthropicはこれでコンテキスト使用量が85%以上削減されると報告している。CodexとOpenCodeはセッション開始時にすべての設定済みMCPツール定義をコンテキストに読み込む。OpenCodeのドキュメントはコンテキストが速く埋まるため有効にするサーバーを制限するよう明示的にユーザーに警告している。
ハーネスがこれを処理してくれない場合は自分で管理する:プロジェクトごとに接続するMCPサーバーを選択的にし、検索ベースの発見が実際に機能するよう具体的でキーワードリッチなツール説明を書く。一方、コンテキストと推論トークンを節約するために無関係または未使用のMCPを切断することも確認する。
■ R.P.Iでより高い抽象レベルで作業する
軽い設定ファイルと最小限のツールセットが整ったら、次の決断はプロンプトの構造化方法だ。HumanLayerのR.P.Iフレームワークは有用なガイドラインだ:ハーネスとインタラクションする際、すべてのプロンプトは正確に3つのことのうち1つをすべきだ。
【Research(リサーチ)】
コードベースがユニークで複雑なら、エージェントに問題文を与え、構造を探索させる——先行事例、関数定義、ファイルの関連性を含む。このステップでアクションは取ってはならない。
【Plan(プラン)】
エージェントがステップバイステップの実行計画を書く。人間はコードベースに関するコンテキストとドメイン知識を考慮して、生成された計画を積極的にレビューし検証すべきだ。このステップで考えを外注したり怠けたりすると、後で高くつく。
【Implement(実装)】
承認された計画をメインウィンドウと呼べる新しいコンテキストウィンドウで実行する。これはスタックの底だ。計画が長くて不安なら、それぞれのセッションを持つサブエージェントのパターンを使うことをお勧めする——サブタスクの無関係な中間状態と反復的思考がメインコンテキストウィンドウを汚染しない。
ハーネスを操作することは、最高のスタッフエンジニアが問題解決に向き合う方法でそれを動作させることだ:問題をサブ問題に分解し、実装前に計画し、計画の第二の目を得る。抽象化はコード行単位からプロンプトにシフトしたが、根底にある規律は変わっていない。
■ サブエージェントを使ってクリーンなコンテキストを維持する
サブエージェントのコアヒューリスティックはシンプルだ:作業のサマリーがメインエージェントに十分な時に使う。中間コンテキストが必要なら——「これは以前に見たものとどう繋がるか」と尋ねたいなら——プライマリウィンドウに保持する。メインエージェントは推論する必要がない中間ステップの作業のみを委任すべきだ。例えば、サブエージェントに委任できるタスクは、メインコンテキストウィンドウが知る必要なく、最終結果のみが重要な一連のツール実行(取得など)だ。サブエージェントはメインの会話をクリーンに保ちながら、無関係な以前のメッセージなしに「スマートゾーン」にサブエージェントを保つ。
サブエージェントに適した2つのパターン:
【並列ファンアウト】
調査とリサーチに最も効果的だ。アラートが発火した時、エージェントは問題を調査し、根本原因の3つの候補理論を生成し、各理論を同時並行で調査するサブエージェントを起動できる。各サブエージェントは独立してログ、トレース、メトリクスを掘り下げる。メインエージェントは自分のコンテキストに数百のログ行を持つことなく3つのサマリーを受け取り結論を統合する。価値はスピードとコンテキストの分離だ:3つの並列検索は3つの順次検索より速く終わり、ノイズは隔離されたまま。同じパターンは複数のモデルから同時に出力が欲しい時にも適用できる。
【パイプライン】
パイプラインはファンアウトが幅を探索するのに対して深さを強化する。機能を順次的なロールを通して押し進める:ユーザーエクスペリエンスを評価するUXデザイナー、技術的実現可能性を評価するアーキテクト、仮定をストレステストするデビルズアドボケート。各ステージは前のステージの出力を受け取り分析を加える。メインエージェントは3つのレンズをすべてコンテキストに保持せずに層化された多角的な評価を得る。これはLLMのような非決定論的システムに特に有益だ。
■ テイクアウェイ:コミットする
ハーネスがタスクに失敗した時の誘惑はハーネスを切り替えることだ。すべてのセットアップを試すなと言っているのではない(Cursor、Claude Code、OpenCode、Codex、DeepAgent CLI含めて)。単に言いたいのは、1つを自分のワークフローに本当に合わせるために時間を投資する必要があるということだ。異なるハーネスは制約、コンテキストウィンドウ戦略、ツールルーティングロジックが異なる——常に切り替えることは設定ファイルにエンコードされた知識を失い、失敗ケースログをゼロからスタートすることを意味する。
だから推奨は、チームのユースケースの大部分をカバーするハーネスを選び(別の投稿でハーネスの選び方を解説予定)、すべての失敗をデータポイントとして扱う:何が、どのステップで、どんな条件下で壊れたか。それを.mdファイルに追加し、プロンプト戦略を相応に変える。最高のハーネスは自分がカスタマイズしイテレーションしたハーネスだ——チームの使用を通じてスムーズにされたエッジケースを処理できるもの。

harness-designagent-opsclaude-workflow
ハーネス設計:スラッジを生まない3原則
♥ 236↻ 27
原文を表示 / Show original
Engineers used to argue about IDEs, now we argue about harnesses.
I've been using and contributing to open-source harnesses (Roo Code, DeepAgent CLI, HumanLayer), and here's what I wish I knew on day one: there are three things you can do right now to make your harness output orthogonal to slop. Yet all three still require human judgment.
This guide covers these simple surfaces that separate harnesses that compound your output from ones that compound your mistakes: how to keep your config files lean enough to reason over, how to structure prompts using the R.P.I. framework so the model approaches problems the way a staff engineer would, and how to use subagents to keep your main context window clean.
By the end, you'll have a concrete set of changes you can make to your setup today, and a clearer sense of why the harness, not just the model, is where your engineering judgment makes a difference.
If the model is the source of intelligence, then the harness is what makes that intelligence useful. The harness’s primary job is to act as the scaffolding that:
Manages the context in an inherently stateless LLM via sessions and compressions
Makes functions like tool calls, I/O processing, and guardrails work around the model.
Think of a harness as a `while (have next message) do {tool}` loop. One smooth harness amplifies your speed and quality of all code generated onwards.
Keep your .md files lean and human-written
The core shortcoming for agents today is the concept of “instruction budget”. To paraphrase Kyle from HumanLayer, frontier thinking LLMs can only follow a few hundred instructions before entering the “dumb zone”, where it starts to miss attending relevant instructions amongst the bloat. Giving too many instructions is functionally encouraging the model to hallucinate.
For a global system prompt — ClAUDE.md or AGENTS.md — human-written outperforms LLM-generated. ETH research found LLM-generated system prompts degrade performance while costing ~20% more in inference. Describe the minimal requirements: what the project is, who the end users are. Every token should fight for its place, since it will be injected globally on every session.
While instinct is front-load everything the model might need and prescribe if-else rules in as much detail as possible, parsing long context directly consumes valuable space in the context window, forcing the reasoning window to drop.
Instead, apply Progressive Disclosure: only let the agent pull context when needed, and let it know what exists by giving individual .md files descriptive names. Here's how that plays out across the three common interfaces.
CLIs
Engineers already use progressive disclosure in CLIs without naming it. You run --help to see available subcommands, then drill into a specific subcommand's --help for its flags. The agent can do the same. This matters most for CLIs the model has never seen — a custom internal tool that wraps your API has zero training data. Without progressive disclosure, you'd need to paste the entire reference into context. With it, the agent runs mycli --help, finds the relevant subcommand, then runs mycli deploy --help to get specific flags. The model discovers commands for the tool as needed the same way you would, and context stays clean.
Popular tools like kubectl or gh don't demonstrate this well because the model already knows their interfaces from training data. The real test is the CLI nobody outside your company has ever used. This also makes CLIs one of the cleanest uses of your CLAUDE.md or AGENTS.md. Rather than bloating those files with behavioral rules, use a few lines to document how to invoke a CLI the model isn't trained on. For example, uv is gaining adoption fast but models still fumble its flags and subcommands. A short line like "use uv for Python package management, run uv --help to discover subcommands before assuming syntax" gives the agent an entry point without wasting context on a full reference.
Skills
This is where the industry has converged. Claude Code, Codex, and OpenCode all implement progressive disclosure for skills the same way: at startup, only the name and description of each skill are loaded into context. The full SKILL.md instructions are read only when the agent decides a skill is relevant to the current task. Skills can point to reference files or scripts, which only load as needed. Write a clear, specific description and the agent can match on it without ever reading the body. Codex's own docs explicitly call this "progressive disclosure" and credit it as core to keeping context clean. As the engineer, this concretely means it is helpful to maintain specific instructions (skills) in separate files with clear naming conventions across your codebase that the agent can retrieve based on requests.
MCP tools
This is where harnesses diverge significantly.
Claude Code ships with built-in MCP tool search: at session start, it loads a lightweight index of tool names, then searches and pulls full schemas on demand — Anthropic reports this reduces context usage by over 85%. Codex and OpenCode load all configured MCP tool definitions into context at session start. OpenCode's docs explicitly warn users to limit which servers they enable because context fills fast.
If your harness doesn't handle this for you, manage it yourself: be selective about which MCP servers you connect per project, and write tool descriptions that are specific and keyword-rich so any search-based discovery actually works. On the other hand, also make sure to disconnect irrelevant or unused MCPs to save on context and inference tokens.
Use R.P.I to work in a higher abstraction
With lean config files and a minimal tool set in place, the next decision is how to structure your prompts. HumanLayer's R.P.I framework is a useful guideline: every prompt should do exactly one of three things when interacting with the harness.
Research: If the code-base is unique and complex, give the agent the problem statement, and let it explore the structure including prior art, function definitions, and how files are related to each other. It is important that no action is taken at this step.
Plan: The agent writes a step-by-step execution plan. The human should proactively review and verify the validation of the generated plan, given your contextual and domain knowledge around the codebase. Outsourcing thinking or being lazy at this step will cost you dearly later on.
Implement: Execute the approved plan in a new context window that we can call the main window. This is the bottom of your stack. If the plan is long and intimidating, we suggest using a pattern of subagents each in its session so irrelevant intermediate states and iterative thinking for a subtask is not polluting the main context window.
Operating a harness is leading it to behave in a way the best staff engineers approach problem-solving: break problems into subproblems, plan before implementing, get a second set of eyes on the plan. The abstraction has shifted from line-by-line code to prompts, but the underlying discipline has not changed.
Use subagents to maintain clean context
The core heuristic for subagents is simple: use one when a summary of the work is sufficient for your main agent. If you need the intermediary context — if you'll want to ask "how does this connect to what I looked at earlier" — keep it in your primary window. The main agent should only delegate work whose intermediate steps it doesn't need to reason about. For example, a task that can be delegated to a subagent is a series of tool executions (such as retrieval) that the main context window doesn’t need to know about, and only the end result is important. Subagents keep the main conversation clean while keeping the subagent in the “smart zone” without giving it irrelevant earlier messages.
Two patterns work well for subagents:
Parallel fan-out
This works best for investigation and research. When an alert fires, your agent can research the issue, generate three candidate theories for root cause, then spin up a subagent for each theory to investigate simultaneously. Each subagent digs into logs, traces, and metrics independently. The main agent gets back three summaries and synthesizes a conclusion without ever having hundreds of log lines in its own context. The value is speed and context isolation: three parallel searches finish faster than three sequential ones, and the noise stays contained. We built a rudimentary version of this previously at Baseten (here) when gpt-oss-120b launched. The same pattern also applies when you want outputs from multiple models concurrently e.g. spinning up one thread of MiniMax M2.5 and one thread of GLM-5.
Pipelines
Pipelines enforce depth where fan-out explores breadth. Push a feature through sequential roles: a UX designer who evaluates user experience, an architect who assesses technical feasibility, a devil's advocate who stress-tests assumptions. Each stage receives the previous stage's output and adds analysis. The main agent gets a layered, multi-perspective evaluation without holding all three lenses in context at once. This is especially beneficial for non-deterministic systems like LLMs. Going beyond this, you could use a frontier model as a judge to consolidate the responses and ensure the desired behavior is achieved with higher confidence.
Takeaway: Commit
There is a temptation when a harness fails on a task is to switch harnesses. We are not saying don’t try all the setups out there, from Cursor, Claude Code, OpenCode, Codex, to Deep Agent CLI; we are simply saying that you need to invest time into molding one truly for your workflow. Different harnesses have differing constraints, context window strategies, and tool routing logic– constantly switching means you lose the institutional knowledge encoded in your config files and start the failure-case log from zero.
So our recommendation is to pick the harness that covers the majority of your team’s use case (stay tuned on how to pick a harness in another post) and treat every failure as a data point: what broke, at which step, under what conditions. Add that to your .md files and change up prompting strategies accordingly. The best harness is the harness that you have customized and iterated on with human engineering; it’s the one that can handle edge cases which are smoothed out through your team’s usage.