評価基準の導入:エージェントが自身の作業を評価・修正する仕組みを発表
LangChain は Deep Agents に RubricMiddleware を導入し、エージェントが定義された評価基準に基づいて自己評価・修正を繰り返すことで、タスク完了の確実性を高める機能を追加した。
キーポイント
RubricMiddleware の機能
エージェントが一度で完璧な出力を出せない課題に対し、定義されたルブリック(評価基準)に基づいて自己評価と反復修正を行う仕組みを提供する。
専用グラダーサブエージェントの活用
単なるルールチェックではなく、ツールを呼び出し会話履歴を推論できる専用のグラダーサブエージェントが評価を担当し、詳細なフィードバックを返す。
明確な完了条件の実現
テストスイートの通過や必須セクションの網羅など、「完了」の定義が明確なタスクにおいて、手動での再実行や診断を不要にする。
影響分析・編集コメントを表示
影響分析
この発表は、AI エージェントの信頼性を飛躍的に高める重要なステップであり、開発者が複雑なタスクを手動で監視・修正する負担を大幅に軽減します。特に、テスト駆動開発やコンプライアンスチェックなど、厳格な品質基準が求められる現場での実用性が向上し、自律型エージェントの実装ハードルを下げる効果があります。
編集コメント
エージェントの「自己完結能力」を高めるための実用的なアプローチであり、特に品質保証が必要な業務自動化において即座に活用できる機能です。

主なポイント
- エージェントは往々にして、方向性は正しいものの、最初の試行では完全に目標を達成できない出力を生成します。
- RubricMiddleware(評価基準ミドルウェア)とは、エージェントに対して「完了」の状態がどのようなものかを指示し、その状態に達するまで継続させるための仕組みです。
- テストの合格、禁止パターンの回避、必須セクションのカバーといった、明確で検証可能な成功基準を持つタスクにおいて最も効果的です。
エージェントはかつてないほど複雑なタスクを担うようになっています。しかし、往々にしてゴールラインに到達できません。これを解決するために、Deep Agents に RubricMiddleware を追加しました。評価基準(ルブリック)を定義すると、エージェントは自己評価を行い、すべての基準を満たすか、設定された上限に達するまで反復処理を行います。
Claude Code や Codex の /goal コマンドにご存知の方には馴染みのあるパターンです。ただし本実装はより柔軟性が高く、評価はツールを呼び出したり、完全なトランスクリプトを推論したり、基準ごとのフィードバックを返却できる専用のグラダー(採点者)サブエージェントによって行われます。
課題
一部のエージェントタスクには、「完了」の明確な定義が存在します。コードのリファクタリングはテストスイートが合格した時点で完了し、レポートは必須セクションすべてがカバーされた時点で完成となります。
しかし、エージェントは必ずしも最初の試行で目標を達成できるわけではありません。コンテキストが大きくなるにつれて、曖昧な指示やツールの誤用、非決定論的なエラーが複合的に作用し、出力の質は低下します。その結果、開発者は手動で診断とタスクの再実行を行う必要に迫られます。
仕組み
エージェントの実行が完了する前に、別の評価者サブエージェントがルブリック(評価基準)に基づいてレビューを行います。すべてが合格すれば実行は終了しますが、何か要件を満たさない場合、評価者の各項目ごとのフィードバックが会話履歴に戻され、エージェントが再実行されます。このループは、ルブリックの条件が満たされるか、設定された反復回数の上限に達するまで続きます。
image.svg)
ループは、条件が満たされた場合(satisfied)、最大反復回数の上限に達した場合(max_iterations_reached)、失敗した場合(failed)、または評価者にエラーが発生した場合(grader_error)に終了します。
実装方法
ここでは最小限の設定をステップごとに説明します。重要なポイントは、RubricMiddleware を一度定義し、深いエージェント(deep agent)にアタッチした上で、呼び出し時にルブリック文字列を渡すことです。(もしルブリックが指定されていない場合、ミドルウェアは何も実行しません。)
1) RubricMiddleware の定義
この ミドルウェア は、ベースエージェントの上に*評価者ループ*を追加するものです。評価者は以下のように設定されます:
- model: 採点に使用される大規模言語モデル(通常、メインのエージェントモデルよりも小さく安価なもの)
- system_prompt: グレーダーの役割と「良い」状態の定義を定める指示
- tools: グレーダーが証拠を集めるために呼び出せるオプションのツール(例:テストの実行、リンティング、出力の検証)
- max_iterations: 実行停止前に発生する修正→再採点ループの最大回数
from deepagents import RubricMiddleware
rubric_middleware = RubricMiddleware(
model="anthropic:claude-haiku-4-5",
system_prompt="You are a code reviewer grading generated code against a rubric.",
tools=[run_test_suite],
max_iterations=5,
)
2) Deep Agent に渡す
あなたの Deep Agent にも、独自の「運用指示」を持たせる必要があります。エージェントの system_prompt は*作業をどのように行うか*を伝え、一方、ルブリックはグレーダーに対して*作業をどのように評価するか*を伝えます。
以下のスニペットでは:
- model: 解決策の生成に使用される大規模言語モデル
- system_prompt: エージェントに対するコーディング規約と制約
- middleware: rubric_middleware を付加し、エージェントが反復的に修正できるようにする
from deepagents import create_deep_agent
agent = create_deep_agent(
model="anthropic:claude-sonnet-4-6",
system_prompt=(
"You are a careful Python engineer. Write correct, readable code. "
"Follow the user's instructions exactly."
),
middleware=[rubric_middleware],
)
3) 人間のメッセージとルブリックで呼び出す
呼び出し時には、以下を提供します:
- messages: 人間の要求(およびオプションで過去のやり取り)
- rubric: グレーダーが満足すべき項目を改行区切りで記したチェックリスト
from langchain.messages import HumanMessage
result = agent.invoke(
{
"messages": [
HumanMessage(
content=(
"入力リストに 2 回以上出現するすべての要素を、最初に出現した順序で返す Python 関数 find_duplicates(lst) を記述してください。"
)
)
],
"rubric": (
"- run_test_suite ですべてのテストがパスすること\n"
"- 関数名は find_duplicates であり、単一のリスト引数を受け取ること\n"
),
},
config={"configurable": {"thread_id": "code-generation-session"}},
)
print(result["messages"][-1].text)
グレーダーに正しさについて抽象的に推論させるのではなく、動作を直接検証するための run_test_suite ツールを提供します。グレーダーは判断を下す前にツールを呼び出して確実な証拠を集めることができ、ツールが提供されていない場合はトランスクリプトからの推論に頼ります。
実践での確認
上記のコード生成例では、エージェントの最初の試行は一見正しく見えたものの、1 つのテストで失敗しました。グレーダーは次のように返しました:
*「1 つのテストが失敗しています: test_unhashable。入力リスト内にリストなどのハッシュ化できない型が含まれていると、関数が TypeError でクラッシュします。」*
エージェントは実装を修正し、2 回目のイテレーションですべてのテストに合格しました。フィードバックは単なる「もう一度試してください」という一般的なものではありません。各基準ごとに独自の判定が下されるため、エージェントは具体的に何を修正すべきかを正確に把握できます。
完全な例についてはこちらのトレースをご覧ください。
なぜ重要なのか
エージェントの出力は確率的な性質を持っています。同じプロンプトでも、ある実行では成功しても、次の実行では不十分になることがあります。RubricMiddleware は、このばらつきを検出する負担を開発者からシステム側へ移します。
手動で出力を確認して失敗したタスクを再実行するのではなく、「完了」の基準を一度定義すれば、ループがその後の処理を担当します。各リトライは情報に基づいたものとなり、グラダー(採点者)が問題を正確に特定し、ターゲットを絞った基準ごとのフィードバックを生成します。
結果として、正解性が重要なタスクにおいて、より信頼性の高いエージェントを実現できます。
さらに詳しく知る
RubricMiddleware はベータ版であり、API は今後変更される可能性があります。設定、観測性(オバザビリティ)、およびルブリックの永続化を含む完全なウォークスルーについては、ドキュメントをご覧ください。
関連コンテンツ

エージェントアーキテクチャ
ディープエージェント
オープンソース
スキルとインタプリタを用いたエージェントのワークフロー構築

ハンター・ロベル
2026 年 5 月 29 日
13 分

LangChain
オープンソース
LangGraph
トークンストリームからエージェントストリームへ


C. ブロマン、
N. ホロン
2026 年 5 月 21 日
9 分
image.png)
パートナー
Deep Agents(深層エージェント)
LangSmith
Deep Agents、LangSmith、および You.com Finance Research API を用いた EU のマクロ経済分析



image.png)
S. Tangedipalli,
K. Singh,
S. Sharma,
A. Pothana
2026 年 5 月 20 日
18 分
エージェントが実際に何をしているかを確認する
LangSmith は、エージェントエンジニアリングプラットフォームであり、開発者がすべてのエージェントの意思決定をデバッグし、評価変更を行い、ワンクリックでデプロイできるように支援します。
原文を表示

Key Takeaways
- Agents often produce outputs that head in the right direction but don't fully land on the first attempt.
- RubricMiddleware is how you tell the agent what "done" looks like — and make it keep going until it gets there.
- Most effective for tasks with clear, verifiable success criteria like passing tests, avoiding forbidden patterns, covering required sections.
Agents are taking on more complex tasks than ever. More often than not, they fall short of the finish line. We've added RubricMiddleware to Deep Agents to fix that: you define a rubric, and the agent self-evaluates and iterates until it satisfies every criterion, or hits a configured cap.
If you're familiar with /goal in Claude Code or Codex, this is a similar pattern. This implementation is a bit more flexible because evaluation is handled by a dedicated grader sub-agent that can call tools, reason over the full transcript, and return per-criterion feedback.
The problem
Some agent tasks have a clear definition of "done." A code refactor is finished when the test suite passes. A report is complete when every required section is covered.
But agents don't always get there on the first try. As context grows larger, ambiguous instructions, tool misuse, and non-deterministic errors all compound — output quality deteriorates, and developers are left to diagnose and re-run tasks manually.
How it works
Before the agent run finishes, a separate grader sub-agent reviews it against the rubric. If everything passes, the run concludes. If anything falls short, the grader's per-criterion feedback is injected back into the conversation and the agent runs again. The loop terminates when the rubric is satisfied, or when a configured iteration limit is hit.
.svg)
The loop terminates on satisfied, max_iterations_reached, failed, or grader_error.
Wiring it up
Here's the minimal setup, broken into steps. The key idea: define a RubricMiddleware once, attach it to a deep agent, then pass a rubric string at invoke time. (If rubric is absent, the middleware does nothing.)
1) Define RubricMiddleware
This middleware adds a *grader loop* on top of the base agent. The grader is configured with:
- model: the LLM used for grading (often smaller/cheaper than your main agent model)
- system_prompt: instructions that define the grader’s role and what “good” looks like
- tools: optional tools the grader can call to gather evidence (e.g., run tests, lint, validate outputs)
- max_iterations: the maximum number of fix → re-grade loops before the run stops
from deepagents import RubricMiddleware
rubric_middleware = RubricMiddleware(
model="anthropic:claude-haiku-4-5",
system_prompt="You are a code reviewer grading generated code against a rubric.",
tools=[run_test_suite],
max_iterations=5,
)
2) Pass it to a deep agent
Your deep agent should also have its own “operating instructions.” The agent’s system_prompt tells it *how to do the work*, while the rubric tells the grader *how to judge the work*.
In the snippet below:
- model: the LLM used to generate the solution
- system_prompt: coding conventions + constraints for the agent
- middleware: attaches rubric_middleware so the agent can be iteratively corrected
from deepagents import create_deep_agent
agent = create_deep_agent(
model="anthropic:claude-sonnet-4-6",
system_prompt=(
"You are a careful Python engineer. Write correct, readable code. "
"Follow the user’s instructions exactly."
),
middleware=[rubric_middleware],
)
3) Invoke with a human message + rubric
At invocation time you provide:
- messages: the human request (and optionally prior turns)
- rubric: a newline-delimited checklist that the grader must mark satisfied
from langchain.messages import HumanMessage
result = agent.invoke(
{
"messages": [
HumanMessage(
content=(
"Write a Python function find_duplicates(lst) that returns a list of "
"all elements that appear more than once in the input list, in the order "
"they first appear."
)
)
],
"rubric": (
"- All tests pass in run_test_suite\n"
"- The function is named find_duplicates and accepts a single list argument\n"
),
},
config={"configurable": {"thread_id": "code-generation-session"}},
)
print(result["messages"][-1].text)
Rather than asking the grader to reason abstractly about correctness, we give it a run_test_suite tool to verify behavior directly. The grader can call tools to gather hard evidence before producing a verdict — and falls back to reasoning from the transcript when no tools are provided.
Seeing it in practice
In the code generation example above, the agent's first attempt looked correct but failed one test. The grader returned:
"One test fails: test_unhashable. The function crashes with TypeError when encountering unhashable types like lists within the input list."
The agent revised its implementation and passed all tests on the second iteration. The feedback isn't a generic "try again" — each criterion gets its own verdict, so the agent knows exactly what to fix.
See the full example in this trace.
Why it matters
Agent outputs are probabilistic: the same prompt can succeed on one run and fall short on the next. RubricMiddleware shifts the burden of catching that variance away from the developer and onto the system.
Instead of manually inspecting outputs and re-running failed tasks, you define what "done" looks like once and the loop handles the rest. Each retry is informed — the grader identifies exactly what's wrong and produces targeted, per-criterion feedback.
The result: more reliable agents on tasks where correctness matters.
Learn more
RubricMiddleware is in beta and the API may change. For a full walkthrough including configuration, observability, and rubric persistence, see the documentation.
Related content

Agent Architecture
Deep Agents
Open Source
Building workflows for agents with Skills and Interpreters

Hunter Lovell
May 29, 2026
13
min

LangChain
Open Source
LangGraph
From Token Streams to Agent Streams


C. Bromann,
N. Hollon
May 21, 2026
9
min
.png)
Partner
Deep Agents
LangSmith
EU macroeconomic analysis with Deep Agents, LangSmith, and the You.com Finance Research API



.png)
S. Tangedipalli,
K. Singh,
S. Sharma,
A. Pothana
May 20, 2026
18
min
See what your agent is really doing
LangSmith, our agent engineering platform, helps developers debug every agent decision, eval changes, and deploy in one click.
関連記事
深層エージェントにおけるコンテキスト管理
LangChain Blog は、複雑なタスクを処理する深層エージェントの性能向上のために、コンテキストを効果的に管理・最適化する手法について解説している。
LangSmith のノーコードエージェントビルダーの紹介
LangChain が提供する LangSmith に、プログラミング不要で AI エージェントを構築できる新機能が導入された。
マルチエージェントシステムをいつどのように構築するか
LangChain は、複数の AI エージェントが協調して複雑なタスクを解決するマルチエージェントシステムの設計手法と実装タイミングについて解説している。
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み