エージェントハッチは自己修復するべきである(8 分読了)
この記事は、AI エージェントの運用失敗時に従来の観測ツールが「何が起きたか」しか示さない現状を指摘し、エージェント自体が自己修復を行うためのハネス設計の重要性と、その実装におけるエンジニアリングの限界について論じています。
キーポイント
観測ツールの本質的限界
現在の観測ツールは実行トレースやコストを詳細に示すが、失敗の原因分析や修正方法、再発防止策については何も提供できないという課題がある。
手動デバッグの非効率性
開発者はトレースを手動でスキャンして仮説を立て、パッチを適用するが、これは時間がかかり、既存機能を壊すリスクや、新モデルによる新たな失敗モードへの対応という無限ループを生む。
ハネス(Harness)の重要性
Cursor の事例のように、モデルそのものよりも、プロンプト・ツール・チェックを組み合わせた「ハネス」の質が結果を左右し、この層の維持管理は終わりのない作業となる。
自己修復型エージェントへの転換
観測データに基づき人間が介入する従来のフローから、エージェント自身が失敗を検知して修正を行う「自己修復」機能を持つハネス設計へパラダイムシフトが必要である。
デバッグループの現状確認
エージェントスタックにおける観測性(observability)の現状と、チームが現在直面しているデバッグプロセスのボトルネックを特定するよう求めています。
オープンソースツールの提案募集
AIエンジニアに愛されるオープンソースツールを開発している場合は連絡を歓迎しており、自社テストを通過した製品のみを紹介・記事化すると明言しています。
影響分析・編集コメントを表示
影響分析
この記事は、AI エージェントの実装における「観測」と「修復」の分離という根本的な課題を浮き彫りにし、単なる監視ツールから自律的な自己修復機能を持つシステムへの進化が必要だと示唆しています。開発者にとっては、モデルの性能向上だけでなく、ハネス層の堅牢性と自動化されたデバッグワークフローの構築が、生産環境での安定稼働に不可欠であることを再認識させる重要な提言です。
編集コメント
従来の AI 監視ツールの限界を鋭く指摘し、次世代のエージェント運用には「自己修復」能力が必須であることを説いた、非常に示唆に富む記事です。開発者は単なるログ分析から、自律的な修正プロセスを持つハネス設計へと視点を移す必要があります。
AI エージェントが本番環境で失敗した際、観測ツールはそれが何をしたかを正確に示しますが、どのように修正すればよいかについてはほとんど何も教えてくれません。
実行のクリーンなトレース、発火したすべてのモデル呼び出しとツール、各ステップにかかった時間、そしてトークンコストが得られます。
しかし、なぜ壊れたのか、何を修正すればよいのか、あるいは来週同じことが起きないという保証については何も得られません。
そのため、トレースをスパンごとにスクロールして何が間違っていたかの仮説を立て、手動でパッチを書き、以前動作していたものを壊さないことを祈るしかありません。
すると新しいモデルがリリースされ、新たな失敗モードのバッチと共に、あなたは最初からその手動ループを再び実行することになります。
真のボトルネックは観測ツール自体ではありません。トレースが画面に到着した後に起こらなければならないすべてのことです。
点線の左側にあるものは自動的に実行されます。点線の右側にあるものはあなたの時間で行われるもので、これが本番環境でのデバッグの実態です。
Cursor は最近、彼らのエージェントを取り巻くハッチ(harness)にどれほどのエンジニアリングが費やされているかを共有しました。これは生モデルを囲むプロンプト、ツール、チェックの層のことです。同じモデルでもより良いハッチを使えばはるかに良い結果が得られ、この作業は決して終わることがありません。
これがすべての観測プラットフォームがあなたに残す場所です。何が起きたかには答えますが、なぜ起きたのか、何を修正すべきか、そして再び壊れないようにするにはどうすればよいかについては、それを手渡すだけです。
そのギャップこそが、現在の多くのチームが閉じ込められているループです。これがなぜ繰り返し開いてしまうのか、そしてこれを最終的に閉じるために何が必要なのかについて説明します。
ほとんどのエージェント観測プラットフォームは、トレースを提供してそこで終わってしまいます。
スパンツリー、レイテンシの数値、トークンコスト、そしてダッシュボードが得られます。しかし、なぜ失敗したのか、何を修正すべきか、あるいは二度と壊れないという保証は得られません。
- 「何が起きたか」→ プラットフォームが対応
- 「なぜ起きたか」→ 手動
- 「ここが修正案です」→ 手動
- 「もう二度と壊れません」→ 手動
これは 2023 年であれば妥当な製品でした。しかし、今日プロダクションでエージェントを運用しているチームにとっては、不適切な抽象化です。
この問題は複合的に悪化します。モデルのアップグレードごとに新たな失敗モードが導入され、新しいツールを追加するたびに新たなエッジケースが発生します。ハッチ(基盤)は、どのチームも手動で追跡・修復できる速度よりも急速に複雑化していきます。
これを可能にするスタックがこちらです。
ほとんどのプラットフォームはダッシュボードで終わってしまい、残りの作業をユーザーに任せてしまいます。右側にあるのは、Opik が独自に実行するループです。
Opik は、AI エージェントおよび LLM(大規模言語モデル)アプリケーション向けのログ記録、デバッグ、最適化プラットフォームです。Opik の構築の前提は、このループを人的リソースで対応させるのではなく、自動化すべきものであるという点にあります。
Opik のアーキテクチャは、一つのつながったワークフローです。
トレース → Ollie が診断 → Ollie が修正案を提案 → 修正が適用され検証される → テストスイートがその失敗を回帰テストとして固定 → 再びトレースへ
この 4 つの層は別々の機能ではありません。それぞれが単一のループ内で相互に作用し、自動的に完結します。
各層について説明します。
すべての LLM(大規模言語モデル)呼び出し、ツール呼び出し、および検索ステップは、単一のデコレータで自動的に計測されます。
import opik⟦CODE_0⟧
@opik.track
def my_agent(query: str):
# your agent logic here
...
LangGraph、CrewAI、および 50 以上のフレームワークと、そのままの状態で動作します。すべてのトレースは、後で失敗した入力を再実行する必要がある際に完全な再現性を確保するために、アクティブだったエージェント構成を記録します。
これら 4 つの層は別々の機能ではありません。それらは互いに連携し、自身で完結する単一のループの中で機能します。
他のすべての観測プラットフォームは「これがあなたのトレースです」で終わりますが、Opik は Ollie によって駆動され、トレースから修正済みのコードへと至ります。
Ollie は Opik に組み込まれたコーディングエージェントです。1 つのエージェントが、完全なコンテキストを扱います。
サイドパネルで修正を進める Ollie は、各ステップの承認後にのみファイルを読み取り編集します。
コードアクセスなしでも、Ollie はスパンツリー(span tree)を読み込み、失敗モードを特定し、すべての LLM 呼び出しにわたる因果連鎖を説明します。「なぜ最終回答が取得されたコンテキストを無視したのか」と尋ねると、Ollie は完全なスパンツリーをたどり、根本原因を浮き彫りにします。
プロジェクトのルートディレクトリから opik connect を実行すると、Ollie がフルコード修正モードにアップグレードされます:
- ソースファイルを読み取る
- 責任のある正確な行を特定する
- ダフ(diff)を提案しますが、明示的な承認がない限り何も変更されません
承認すると、Ollie は元の失敗したトレースからの正確な入力に対してエージェントを再実行し、並列比較のために新しいトレースをストリーミングし、元の失敗をテストスイートの回帰ケースとしてロックします。
悪いトレース → 根本原因 → ダフ → 承認 → 再実行 → 回帰ロック
悪いトレースから承認という手動ステップを唯一の例外として、ロックされた回帰テストに至るまでの完全なパス。
ほとんどの評価ワークフローは、ラベル付きデータセットの構築、数値指標の定義、浮動小数点の比較です。このモデルは研究者には機能しますが、エンジニアが品質について考える方法とは一致しません。
Opik はこれを平易な英語によるアサーションに置き換えます。
python
suite = opik.TestSuite("crm-agent-v2")
suite.add_assertion("The response must include specific deal details, not just a count")
suite.add_assertion("The response must never reveal unauthorized information")
suite.run_tests()
Opik はこれらを内部で LLM-as-a-judge(LLM を判事として用いるチェック)に変換します。各テストケースごとにクリーンな合格/不合格が得られます。
実際の失敗から構築された回帰スイートであり、各アサーションは平易な英語によるチェックとして記述されています。
ワークフローを変える部分:デバッグするたびに失敗したトレースは自動的に新しいテストケースになります。このスイートは、事前に誰かが作成した合成シナリオではなく、実際の生産環境での失敗から成長していきます。
すべてのサイクルで、ハッチ(テスト枠組み)を壊すことがより困難になります。
しかし、テストスイートが成長しても、変更をリリースする前に安全にテストできる場所はまだ必要です。それが Layer 4 の役割です。
ほとんどのプレイグラウンドはプロンプトプレイグラウンドです。システムプロンプトを変更して LLM の呼び出しを再実行するだけです。これは間違った質問に答えていることになります。
本番環境での真の問いは、この部分を変更したときに、エージェントグラフ全体に何が起こるかということです。
Opik の Agent Sandbox は、UI 内で完全なインストゥルメント化されたエージェントをエンドツーエンドで実行します。プロンプトを変更し、モデルを交換し、ツールを追加するだけで、全体のスパンツリーにわたるシステムの反応を観察できます。サンドボックスの実行ごとに、完全な Opik のトレースが生成されます。
開発者以外のステークホルダー、PM(製品マネージャー)、ドメインの専門家、QA は、git を操作することなく安全に設定をテストできます。
これらのレイヤーは独立した機能ではありません。それらは一つのループです。
.track でインストゥルメント化し、opik.Config を宣言します。本番環境で何かが失敗すると、Ollie がトレースを読み、ソースコードを読み、修正案を提案します。あなたが承認すれば、Ollie はサンドボックス内で元の失敗した入力に対してエージェントを再実行します。修正が成功したら、それを新しい Blueprint として保存します。環境ポインタはステージングへプロモートされ、元の失敗は回帰テストとしてロックされます。
エージェントのインストゥルメント化から、次の失敗がトップで入ってくるまでをエンドツーエンドで描いた同じループです。
次の失敗も同じループに入ります。
毎サイクルごとに、ハッチ(枠組み)は壊れにくくなります。
トレースで終わる観測可能性は、エージェントが単純な時代には意味がありました。しかし、本番環境に到達した今、真の作業はトレース後のすべてであり、それが Opik があなたのために実行し、あなたの負担に残さない部分です。
このスタック全体はオープンソースで提供されており、トレーシング、Ollie、テストスイート、Agent Sandbox、6 つのアルゴリズムを持つ Agent Optimizer、そして 50 以上のフレームワーク統合が含まれています。GitHub でのスター数はすでに 19.3K を超えています。
セルフホストは以下の 3 コマンドで可能です:
bash
git clone https://github.com/comet-ml/opik
cd opik
./opik.sh
Cursor が説明する手動ループとは、Opik が不具合のあるトレースからロックされた回帰テストに至るまで、自身で閉じるものです。
プロダクション環境でエージェントを実行している場合は、ぜひご覧ください。
(スター🌟を忘れないでください)
現在、あなたのエージェントスタックにおける観測性の状態はどうなっており、チームにとってデバッグループがどこで破綻していますか?
AI エンジニアに愛されるオープンソースツールを開発している場合は、ご連絡ください。私たちは自社テストに合格したツールのみを取り扱っていますので、まずはあなたのツールを試して、その価値が認められれば記事にします。
本号のスポンサーである Comet ML 氏に感謝いたします。
原文を表示
When an AI agent fails in production, your observability tool shows you exactly what it did and almost nothing about how to fix it.
You get a clean trace of the run, every model call and tool that fired, how long each step took, and what it cost in tokens.
What you don't get is why it broke, the change that would fix it, or any promise the same thing won't happen again next week.
So you scroll through the trace span by span, form a theory about what went wrong, write a patch by hand, and hope it doesn't break something that was working before.
Then a new model ships with a fresh batch of failure modes, and you run that whole manual loop from the top.
The real bottleneck isn't your observability. It's everything that has to happen after the trace lands on your screen.
Everything to the left of the dotted line runs automatically. Everything to the right runs on your time, which is where production debugging actually lives.
Cursor recently shared how much engineering goes into the harness around their agent, the layer of prompts, tools, and checks wrapped around the raw model. A better harness on the same model gives far better results, and that work never really ends.
This is where every observability platform leaves you. It answers what happened, then hands back why it happened, what to change, and how to keep it from breaking again.
That gap is the loop most teams are stuck in today. Here's why it keeps reopening, and what it finally takes to close it.
Most agent observability platforms deliver a trace and stop.
You get a span tree, latency numbers, token costs, and a dashboard. What you don't get: why it failed, what to fix, or any guarantee it won't break again.
- "What happened" → the platform handles this
- "Why it happened" → manual
- "Here's the fix" → manual
- "This won't break again" → manual
That was a reasonable product in 2023. It's the wrong abstraction for teams running agents in production today.
The problem compounds itself. Every model upgrade introduces new failure modes. Every new tool adds new edge cases. The harness gets more complex faster than any team can manually track and repair.
Here's the stack that does it.
Most platforms end at the dashboard and hand the rest to you. The right side is the loop Opik runs on its own.
Opik is an
logging, debugging, and optimization platform for AI agents and LLM applications. Opik is built around the premise that this loop should be automated, not staffed.
Opik's architecture is one connected workflow.
Trace → Ollie diagnoses → Ollie proposes a fix → fix is applied and verified → Test Suite locks the failure as a regression test → back to Trace
The four layers are not separate features. They feed each other in a single loop that closes on its own.
Here's each layer.
Every LLM call, tool invocation, and retrieval step is instrumented automatically with a single decorator.
python
import opik
@opik.track
def my_agent(query: str):
# your agent logic here
...Works with LangGraph, CrewAI, and 50+ frameworks out of the box. Every trace records which agent configuration was active for full reproducibility when you need to rerun a failing input later.
The four layers are not separate features. They feed each other in a single loop that closes on its own.
Every other observability platform stops at "here's your trace." Opik goes from trace to fixed code, powered by Ollie.
Ollie is a coding agent built into Opik. One agent, full context.
Ollie working through a fix in the side panel, reading and editing files only after you approve each step.
Without any code access, Ollie reads span trees, identifies failure modes, and explains the causal chain across every LLM call. Ask it, "why did the final answer ignore the retrieved context?" It walks the full span tree and surfaces the root cause.
Run opik connect from your project root, and Ollie upgrades to full code-fix mode:
- Reads your source files
- Identifies the exact lines responsible
- Proposes a diff; nothing changes without your explicit approval
Once you approve, Ollie reruns your agent against the exact inputs from the original failing trace, streams the new trace for side-by-side comparison, and locks the original failure as a regression case in your test suite.
Bad trace → root cause → diff → approve → rerun → regression locked
The full path from a bad trace to a locked regression test, with your approval as the one manual step.
Most eval workflows: build a labeled dataset, define a numerical metric, compare floats. That model works for researchers. It doesn't match how engineers think about quality.
Opik replaces it with plain-English assertions.
python
suite = opik.TestSuite("crm-agent-v2")
suite.add_assertion("The response must include specific deal details, not just a count")
suite.add_assertion("The response must never reveal unauthorized information")
suite.run_tests()Opik converts those into LLM-as-a-judge checks under the hood. Clean pass/fail per test case.
A regression suite built from real failures, with each assertion written as a plain-English check.
The part that changes the workflow: every failing trace you debug automatically becomes a new test case. The suite grows from real production failures, not synthetic scenarios someone wrote in advance.
Every cycle, the harness gets harder to break.
But even with a growing test suite, you still need a safe place to test changes before they ship. That's what Layer 4 is for.
Most playgrounds are prompt playgrounds. You change a system prompt and rerun one LLM call. That answers the wrong question.
The production question is, what happens to the entire agent graph when I change this.
Opik's Agent Sandbox runs the fully instrumented agent end-to-end inside the UI. Change a prompt, swap a model, add a tool, and watch how the whole system responds across the full spanning tree. Every sandbox run produces a complete Opik trace.
Non-developer stakeholders, PMs, domain experts, and QA can safely test configurations without touching git.
The layers aren't independent features. They're one loop.
Instrument with
.track. Declare an opik.Config. Something fails in production. Ollie reads the trace, reads your source, and proposes a fix. You approve. Ollie reruns the agent in the Sandbox against the original failing input. Fixes passes. Save it as a new Blueprint. The environment pointer promotes to staging. Original failure locked as a regression test.
The same loop drawn end to end, from instrumenting your agent to the next failure entering at the top.
The next failure enters the same loop.
Every cycle, the harness gets harder to break.
Observability that ends at the trace made sense when agents were simple. Once they hit production, the real work is everything after the trace, and that is the part Opik runs for you instead of leaving it on your plate.
The whole stack ships in the open, Tracing, Ollie, Test Suites, the Agent Sandbox, a 6-algorithm Agent Optimizer, and 50+ framework integrations, with the project past 19.3K stars on GitHub.
It self-hosts in three commands:
bash
git clone https://github.com/comet-ml/opik
cd opik
./opik.shThe manual loop Cursor describes is the one Opik closes on its own, from a bad trace all the way to a locked regression test.
It is worth a look if you are running agents in production.
( don't forget to star 🌟)
What's the current state of observability in your agent stack, and where does the debugging loop break for your team right now?
If you are building an open-source tool that AI engineers would love, reach out. We only cover tools that pass our own test, so we'll try yours first and write about it only if it holds up.
Thanks to Comet ML for sponsoring today's issue.
関連記事
Cloudflare が公開トラフィックをプライベートアプリケーションへルーティングする機能を発表
Cloudflare は、従来の CDN や WAF で保護される公開アプリと、VPN やファイアウォールで守られる内部 API・AI エージェントバックエンドなどの境界を撤廃し、両者を統合して管理する新機能を提供すると発表した。
エージェントが2つのHugging Face Spaceを連鎖させて3Dのパリ美術館を構築した方法
Hugging Face Blogは、AIエージェントが2つの異なるHugging Face Spaceを連携させることで、3D形式のパリ美術館を構築するプロセスを紹介している。
エージェントシステムにおける意図と実行の架橋
Amazon Science は、AI エージェントのパフォーマンスはモデル自体の問題ではなく、LLM とツール間の仲介役となるハッチ(OS)の設計がボトルネックであると指摘し、意図を実行に移すシステムの重要性を強調した。
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み