AIニュース最前線
最新ニュースAI日報Hacker日報週報動画AIツールトレンド企業

AIニュース最前線

世界中のAI最新情報を日本語で毎時更新

最新ニュース日報トレンド企業プレミアムRSS
© 2026 ainew.jp特定商取引法に基づく表記
ニュース一覧元記事を開く
AWS Machine Learning Blog·2026年6月16日 03:07·約16分で読める

Strands Evals を用いた AI エージェントの失敗検出と根本原因分析

#AI Agent#Root Cause Analysis#LLM Ops#AWS Bedrock#Strands Evals
TL;DR

AWS は Strands Evals SDK の新機能として、AI エージェントの失敗原因を自動特定し、修正推奨事項を提供する「Detector」機能を公開し、運用コストの削減と開発効率の向上を実現した。

AI深層分析2026年6月16日 04:03
4
重要/ 5段階
深度40%
4
関連度30%
5
実用性20%
5
革新性10%
3

キーポイント

1

従来の評価手法の限界突破

単なる成功率スコア(例:60%)だけでは不十分であり、失敗の原因を特定し、修正すべき箇所(システムプロンプトかツール定義か)を自動で判別する機能が必要である。

2

Detector による自動化診断

Strands Evals SDK に搭載された Detector が実行トレースを分析し、失敗のカテゴリ化、信頼度スコア、因果連鎖の特定を自動で行うことで、診断時間を数時間から数分に短縮する。

3

構造化された修正推奨

単に「なぜ失敗したか」だけでなく、「どこをどう直すべきか」という具体的なアクションプラン(システムプロンプトの修正、ツールの定義変更など)を提示する。

4

多層的な失敗検出

単一のパスで実行エラー(ツールパラメータ)、セマンティック問題(ハルシネーション)、オーケストレーション問題(目標逸脱)など、複数のレベルの失敗を同時に特定できます。

5

根本原因分析による因果関係の解明

検出された失敗に基づいて因果連鎖を追跡し、根本原因と下流の症状を区別することで、修正が必要な箇所を明確に示します。

6

Fix Type の区別による具体的な対策

ツールスキーマの欠陥(TOOL_DESCRIPTION_FIX)とシステムプロンプトの指示不足(SYSTEM_PROMPT_FIX)を明確に分類することで、それぞれの根本原因に対応する個別の修正が可能になる。

7

diagnose_session による統合診断

障害検出と根本原因分析を単一パイプラインとして実行し、重複を除いた推奨事項を含む統一された診断結果を返す機能を提供する。

影響分析・編集コメントを表示

影響分析

本記事は、生成 AI エージェントの生産環境導入における最大の課題である「失敗時のデバッグコスト」を解決する具体的な技術的アプローチを示しています。開発者が手動で原因を追跡する負担を軽減し、AI システムの安定稼働と迅速な改善サイクルを実現することで、エンタープライズレベルでのエージェント運用を加速させる重要な一歩となります。

編集コメント

AI エージェントの運用が本格化する中で、単なる「動作確認」から「自律的な原因究明」へと進化を遂げる重要なツールリリースです。開発現場のボトルネック解消に直結する実用的な機能と言えます。

プロダクション環境で AI エージェントが失敗した際、その事実を知ることは始まりに過ぎません。より難しい問いは「なぜ失敗したのか」そして「何を修正すべきか」です。従来の評価では「このエージェントのゴール達成率は 60% です」という結果しか得られず、何が間違っていたかを理解するために実行トレースを手動でレビューする必要が生じます。大規模にエージェントを運用するチームにとって、この手動診断は問題検出から修正版のリリースまでの間にボトルネックとなります。

Strands Evals SDK の検出機能(Detectors)はこのボトルネックを解消し、エージェントの実行トレース内の失敗を自動的に特定して根本原因分析(Root Cause Analysis)を実行します。これにより、診断にかかる時間を数時間から数分に短縮できます。

本稿では、実際のエージェントの失敗を検証するために検出関数を呼び出す手順を解説します。構造化された出力の解釈方法、すなわち信頼度スコア付きのカテゴリ別失敗分類、根本原因と下流症状を結びつける因果連鎖(Causal Chains)、およびシステムプロンプトまたはツール定義のどちらに修正を加えるべきかを明記する修正推奨事項について学びます。また、すべてのテスト実行で自動診断を行うために、検出機能を評価パイプラインに統合する方法についても解説します。

検出機能は、前回の投稿で紹介した評価フレームワーク Strands Evals を補完するものであり、「エージェントの性能はどうだったか?」という問いだけでなく、「なぜ失敗し、どのように修正すべきか?」という問いにも答えるものです。

前提条件

本記事を追いかけるためには、以下の前提条件を満たす必要があります。

  • Python 3.10 以降。
  • pip install strands-agents-evals を実行して Strands Evals SDK のインストール済み。
  • Amazon Bedrock モデルへのアクセス権限の有効化(検出器は、大規模言語モデル (LLM) ベースの分析を使用します)。
  • Amazon CloudWatch の例を行う場合、logs:StartQuery および logs:GetQueryResults 権限を設定した AWS クレデンシャルが必要。

スコアだけでは不十分な理由

Strands Evals フレームワークは、ケース、実験、評価器を通じて、ゴール達成率、ツール選択の精度、有用性スコアといった信頼性の高い品質指標を提供します。これらは回帰現象の検出や統計レベルでのパフォーマンス理解に重要ですが、回帰を検出した後に何が起こるかを考えてみてください。デプロイ後やビルド時のテストにおけるプロンプトやツールの変更後、エージェントのゴール達成率が 85% から 70% に低下したとします。評価器がその低下を確認しました。次にどうすればよいでしょうか?

失敗を引き起こした具体的な振る舞いを特定し、根本原因を下流の症状から区別し、修正がシステムプロンプトに属するのかツール定義に属するのかを決定し、影響度に基づいて優先順位をつける必要があります。この診断ワークフローは従来、シニアエンジニアがトレースをスパンごとに手動で検査し、数百ステップにわたる失敗を相関させることを必要としており、このプロセスはスケーラビリティに欠けます。

検出器はこのワークフローを自動化します。評価者は、ケースごとのスコアを生成することで「エージェントの成果はどの程度だったか」に回答し、検出器は、分類された失敗、因果連鎖、修正推奨事項を含むスパンレベルでの診断を生成することで「なぜ失敗したのか」に回答します。

検出器の仕組み

検出器パイプラインは、実行トレースに対する LLM ベースの分析によって駆動される 2 つのフェーズで動作します。セッション、トレース、スパンの詳細については、Amazon Bedrock AgentCore のエージェントリソースにおける観測可能性の理解 を参照してください。

フェーズ 1:失敗検出は、セッション内の各スパンを、9 つの親カテゴリに整理された包括的な失敗分類体系に対してスキャンします。これらは、ハルシネーション(幻覚)、誤ったアクション、オーケストレーションエラー、タスク指示非準拠、実行エラー、コンテキスト処理エラー、反復行動、LLM 出力の問題、設定ミスマッチです。特定された各失敗について、スパンの位置、1 つ以上のカテゴリ、信頼度スコア、およびトレースから抽出された証拠を返します。

フェーズ2:根本原因分析は検出された失敗を取り込み、それらの間の因果連鎖を追跡します。単一の上位段階でのミスが、複数の下位段階の失敗に連鎖することがよくあります。根本原因分析では、原因と症状を区別し、各失敗の原因性を(PRIMARY、SECONDARY、またはTERTIARY)分類し、伝播影響を特定し、修正が必要な箇所(システムプロンプト、ツール説明、その他)に基づいて修正推奨事項を生成します。

両方のフェーズは、選択されたDetectorモデルのコンテキストウィンドウ内に収まるセッションに対する直接分析、中規模サイズのセッションに対して祖先および子スパンのみを保持する失敗パスの剪定、非常に大規模なセッションに対してトレースを重複するウィンドウに分割し結果を統合するチャンク化分析とマージという、段階的な戦略を通じてさまざまなサイズのセッションを処理します。

以下の図は、2つのエントリポイントが同じ検出および分析フローに収束するエンドツーエンドのパイプラインを示しています。

image
image

*図:統合型およびスタンドアロン型のエントリポイントから失敗検出と根本原因分析へと流れるDetectorパイプライン。*

失敗検出の始め方

以下の例では、Evaluating AI agents for production: A practical guide to Strands Evals で紹介されている創薬研究アシスタントのセッショントレースを使用します。このエージェントは、Strands Agents と Amazon Bedrock を基盤に構築されています。追従して実行するには、OpenTelemetry によるトレーシングを有効にしてエージェントを実行し、セッションを JSON 形式でエクスポートするか、本記事の後半で紹介する CloudWatchProvider を使用して既存のトレースを取得してください。トレーシングの設定方法やセッションのエクスポート方法は、Strands Agents SDK ドキュメントのユーザーシミュレーション を参照してください。

detect_failures 関数は、Session オブジェクト(Strands Evals の標準トレース形式)を受け取り、構造化された失敗情報を返します。各失敗情報には、発生したスパン、事前定義された失敗分類体系からの一つ以上のカテゴリ、信頼度スコア、およびトレースから抽出された証拠が含まれます。

json
import json
from strands_evals.detectors import detect_failures
from strands_evals.types.trace import Session
from strands_evals.detectors import ConfidenceLevel

with open("agent_trace.json") as f:
    session = Session.model_validate_json(f.read())

result = detect_failures(session, confidence_threshold=ConfidenceLevel.MEDIUM)

for failure in result.failures:

for cat, conf, ev in zip(failure.category, failure.confidence, failure.evidence):

print(f"[{conf}] {cat} at span {failure.span_id}")

print(f" Evidence: {ev}")

The following is output from a research agent that was asked to "Research the impact of energy requirements for powering AI in the real world." The agent encountered tool configuration issues and progressively degraded:

[0.9] execution-error-category-tool-schema at span f503a7d546fa4157

Evidence: Tool execution failed due to missing required parameter

'knowledgeBaseId'. Error: 'Parameter validation failed: Invalid type

for parameter knowledgeBaseId, value: None'

[0.75] hallucination-category-hall-usage at span 0466979670d14099

Evidence: Agent claims 'I don't have access to the specific knowledge

base needed' and then proceeds to provide detailed information about AI

energy requirements 'based on general knowledge' without using any tools.

[0.9] orchestration-related-errors-category-goal-deviation at span d98d578e61233d33

Evidence: Agent completely abandons the original task about AI energy

requirements and instead provides a lengthy response about marine

biology, stating 'I'm going to pivot to discuss marine biology instead.'

一度のパスで、検出器は複数のレベルでの失敗を特定します:実行エラー(ツールパラメータ検証)、意味論的な問題(「一般的な知識」からのハルシネーション)、そしてオーケストレーションの問題(完全な目標の逸脱)。一つのスパンが複数の失敗カテゴリを示すこともあり、それぞれに独立した信頼度と証拠が存在します。

根本原因分析の追加

失敗を特定することは有用ですが、なぜそれが起きたのかを理解することが修正を駆動するものです。analyze_root_cause 関数は検出された失敗を受け取り、それらの間の因果連鎖を追跡し、根本原因を下流の症状から分離して、各修正がどこに属すべきかを推奨します。もし analyze_root_cause に失敗が提供されない場合、自動的に失敗検出を実行します。

from strands_evals.detectors import detect_failures, analyze_root_cause

failures = detect_failures(session)

rca_result = analyze_root_cause(session, failures=failures.failures)

for rc in rca_result.root_causes:

print(f"Causality: {rc.causality}")

print(f" Span: {rc.failure_span_id} | Fix type: {rc.fix_type}")

print(f" Root cause: {rc.root_cause_explanation}")

print(f" Recommendation: {rc.fix_recommendation}")

同じ研究エージェントセッションを継続して、根本原因分析は因果構造を明らかにします:

因果関係:主要失敗

スパン:f503a7d546fa4157 | 修正タイプ:ツール記述の修正

根本原因:エージェントが、retrieve ツールの説明に knowledgeBaseId が必須であることが明確に記載されていないため、必要な knowledgeBaseId パラメータなしで retrieve ツールを呼び出してしまいました。これによりパラメータ検証に失敗し、異なるパラメータ組み合わせでの複数の再試行が強制されました。

推奨事項:retrieve ツールの説明を更新し、knowledgeBaseId を必須パラメータとして明示的にマークするとともに、フォーマット制約と例値を含む明確なドキュメントを追加してください。

因果関係:二次失敗

スパン:0466979670d14099 | 修正タイプ:システムプロンプトの修正

根本原因:すべての検索試行が失敗した後、エージェントは「一般的な知識に基づく」と主張して詳細な AI エネルギー消費情報を捏造しました。これは、ツールで取得した証拠なしに事実に基づくコンテンツを生成することを禁止する指示がシステムプロンプトに含まれていないためです。

推奨事項:検索ツールが失敗した場合、エージェントが研究タスクの完了不能を明示的に認めるよう、かつツールで検証されたソースなしに詳細な事実情報を生成しないよう禁止する指示をシステムプロンプトに追加してください。

修正タイプの区別こそが、根本原因分析を実行可能にする鍵です。ツールスキーマエラーは、検索ツールの knowledgeBaseId が明確に文書化されていないため TOOL_DESCRIPTION_FIX に分類されます。一方、下流でのハルシネーション(幻覚)は、永続的なツール障害への対処方法に関する指示が欠落しているため SYSTEM_PROMPT_FIX に該当します。一つのカテゴリのみを修正しても、もう一方のカテゴリは未解決のまま残ってしまいます。

diagnose_session を用いた統合診断

利便性を高めるため、diagnose_session は両フェーズ(障害の検出、および根本原因の分析)を単一のパイプラインとして実行し、重複を除かれた推奨事項を含む統一された DiagnosisResult を返します:

from strands_evals.detectors import diagnose_session, ConfidenceLevel

result = diagnose_session(session, confidence_threshold=ConfidenceLevel.MEDIUM)

print(f"Found {len(result.failures)} failures, {len(result.root_causes)} root causes")

for rec in result.recommendations:

print(f" - {rec}")

これにより、前述の例で示された障害と根本原因が、推奨事項をすべての根本原因にわたって重複排除した単一の結果としてパッケージ化されます。一つの関数呼び出しから、どこに適用すべきかによって分類された具体的な変更の優先順位リストを得ることができます。

評価パイプラインとの統合

既存の評価ワークフローに検出器を組み込むことで、追加的な価値が得られます。DiagnosisConfig を使用すると、あらゆる実験に自動診断を付与できるため、失敗したテストケースはすべて自動的に診断結果を生成します:

from strands_evals import Experiment

from strands_evals.evaluators import GoalSuccessRateEvaluator

from strands_evals.detectors import ConfidenceLevel, DiagnosisConfig, DiagnosisTrigger

from strands_evals.types.evaluation_report import EvaluationReport

experiment = Experiment(

cases=test_cases,

task_function=my_agent_task,

evaluators=[GoalSuccessRateEvaluator()],

diagnosis_config=DiagnosisConfig(

trigger=DiagnosisTrigger.ON_FAILURE,

confidence_threshold=ConfidenceLevel.MEDIUM

),

)

report = experiment.run()

report.display(include_recommendations=True)

2 つのトリガーモードが利用可能です。ON_FAILURE(デフォルト)は、少なくとも 1 つの評価器が test_pass=False を返した場合のみ診断を実行するため、継続的インテグレーションおよび継続的デリバリー (CI/CD) における回帰検出に対してコスト効率に優れています。ALWAYS は結果に関わらずすべてのケースで診断を実行し、形式的には合格するケースでも最適化されていないパスを特定するのに役立ちます。

この統合により、CI/CD パイプラインは「3 つのテストが失敗しました」と通知するとともに、その理由と修正すべき点を示します。これによりフィードバックループが完結します:ケースを定義し、実験を実行し、スコアと診断結果を同時に取得し、推奨される修正を適用して再実行して確認を行います。

注意: デテクターの実行には、LLM ベースの分析に Amazon Bedrock の推論機能が使用され、課金が発生します。詳細は Amazon Bedrock の価格設定 をご確認ください。Amazon CloudWatch Logs のストレージも課金の対象となります。詳細は Amazon CloudWatch の価格設定 をご覧ください。特に、頻繁に実行される CI/CD パイプラインにデテクターを統合する際は、AWS Cost Explorer で使用状況を確認してください。

Amazon CloudWatch からの本番環境セッションの診断

上記の例ではローカルのセッションファイルを使用していますが、本番環境ではエージェントのトレースが OpenTelemetry を通じて Amazon CloudWatch Logs にリアルタイムで記録されます。CloudWatchProvider はこれらのトレースを直接 Amazon CloudWatch から取得し、デテクターで分析可能な Session オブジェクトに変換します:

python
from strands_evals.providers import CloudWatchProvider
from strands_evals.detectors import diagnose_session, ConfidenceLevel

provider = CloudWatchProvider(agent_name="my-research-agent", region="us-east-1")
data = provider.get_evaluation_data(session_id="abc-123-def-456")
session = data["trajectory"]

result = diagnose_session(session, confidence_threshold=ConfidenceLevel.MEDIUM)

for rc in result.root_causes:
    print(f"[{rc.fix_type}] {rc.fix_recommendation}")

内部では、プロバイダーは Amazon CloudWatch Logs Insights を照会してセッション ID に一致する OTEL (OpenTelemetry) レコードを取得し、スパンメタデータからエージェントフレームワーク(Strands、LangChain、またはその他)を自動検出し、スパンを標準化された Session へマッピングします。この検出機能は Strands エージェントだけでなく、Amazon CloudWatch に OpenTelemetry のトレースをエクスポートするあらゆるフレームワークで動作します。

また、これをオフライン評価用の実験パイプラインと組み合わせることも可能です。CloudWatchProvider を使用して、エージェントを再実行せずに過去の生産環境でのセッションを評価・診断できます。さらに、LangfuseProvider や OpenSearchProvider を用いて、Langfuse または OpenSearch からトレースを取得することも可能です。

ベストプラクティス

MEDIUM 信頼度から開始する。 LOW しきい値は潜在的な問題をより多く検出しますが、ノイズも多いため、特定の失敗事例を深く調査する場合に有用です。MEDIUM は日常利用において良好な信号対雑音比を提供します。HIGH は、高確度の発見のみが必要な生産環境の監視用に確保してください。

CI/CD では ON_FAILURE を、定期的な監査には ALWAYS を使用する。 ON_FAILURE に設定することで、LLM のコストは失敗率に比例し、すべてのテスト実行で実用的になります。サブオプティマルな挙動が合格ケースの中に隠れているのを防ぐため、ALWAYS モードの実行を週次またはリリースごとにスケジュールしてください。

PRIMARY の失敗をまず修正する。二次的および三次的な失敗は、根本原因に対処することで解決することが多い。複数の推奨事項を実装する前に、PRIMARY の失敗を修正することで下流の失敗が解消されるか確認してください。これにより反復サイクルを削減できます。

推奨事項を修正タイプごとにグループ化する。TOOL_DESCRIPTION_FIX に関する変更と SYSTEM_PROMPT_FIX に関する変更をそれぞれまとめてください。これにより、評価を再実行する際に各変更カテゴリの影響を独立して測定可能になります。

事前に検出された失敗を analyze_root_cause に渡す。detect_failures をすでに実行しており、根本原因分析を実行する前に結果を検査したい場合は、重複した検出を避けるために直接渡してください:

failures = detect_failures(session)

... 失敗の検査またはフィルタリング ...

rca = analyze_root_cause(session, failures=failures.failures)

実験にはテストセッションを使用する。本記事で使用されている flawed_session.json は、Strands Evals テストスイートで入手可能です。これを使用してローカルで検出器を試すことができます。

リソースのクリーンアップ

検出関数自体は永続的な AWS リソースをプロビジョニングしません。ただし、エージェントのトレースに対して Amazon CloudWatch Logs のエクスポートを設定している場合は、以下の点を確認する必要があるかもしれません:

  • Amazon CloudWatch ロググループ:ロググループを削除すると、すべてのログデータが永久的に削除され、元に戻すことはできません。続行する前に、保持が必要なログのエクスポートを確認してください。テスト用に作成したロググループがある場合は、Amazon CloudWatch コンソールから削除するか、aws logs delete-log-group --log-group-name コマンドを実行して削除してください。

Amazon Bedrock モデルへのアクセス: LLM 分析には Amazon Bedrock が使用されます。mo

原文を表示

When your AI agent fails in production, knowing *that* it failed is only the beginning. The harder question is *why* it failed and what to fix. Traditional evaluation tells you “this agent scored 60 percent on goal completion,” but leaves you manually reviewing execution traces to understand what went wrong. For teams operating agents at scale, this manual diagnosis becomes the bottleneck between detecting a problem and shipping a fix. Detectors in the Strands Evals SDK remove this bottleneck by automatically identifying failures in agent execution traces and performing root cause analysis, so you can reduce diagnosis time from hours to minutes.

In this post, we walk you through calling the detector functions to diagnose real agent failures. You learn how to interpret their structured output: categorized failures with confidence scores, causal chains linking root causes to downstream symptoms, and fix recommendations specifying whether a change belongs in your system prompt or tool definitions. You also learn how to integrate detection into your evaluation pipeline for automated diagnosis on every test run.

Detectors complement the evaluation framework introduced in a previous post by answering not only “how well did the agent do?” but also “why did it fail and how do I fix it?”

Prerequisites

You must have the following prerequisites to follow along with this post.

  • Python 3.10 or later.
  • Strands Evals SDK installed with pip install strands-agents-evals.
  • Amazon Bedrock model access enabled (detectors use large language model (LLM)-based analysis).
  • For Amazon CloudWatch examples, AWS credentials configured with logs:StartQuery and logs:GetQueryResults permissions.

Why scores alone are not enough

The Strands Evals framework provides reliable quality signals through Cases, Experiments, and Evaluators: goal success rates, tool selection accuracy, and helpfulness scores. These are important for catching regressions and understanding performance at a statistical level. But consider what happens after you detect a regression. Your agent’s goal success rate drops from 85 percent to 70 percent after a deployment or after prompt or tool changes in build-time testing. Evaluators confirm the drop. Now what?

You must identify which specific behaviors caused failures, distinguish root causes from downstream symptoms, determine whether the fix belongs in the system prompt or tool definitions, and prioritize by impact. This diagnosis workflow has traditionally required senior engineers to manually inspect traces span by span and correlate failures across hundreds of steps, and this process doesn’t scale.

Detectors automate this workflow. Evaluators answer “how well did the agent do?” by producing scores at the per-case level. Detectors answer “why did it fail?” by producing diagnoses at the per-span level with categorized failures, causal chains, and fix recommendations.

How detectors work

The detector pipeline operates in two phases, each powered by LLM-based analysis of the execution trace. Refer to Understand observability for agentic resources in Amazon Bedrock AgentCore to learn more about sessions, traces, and spans of agents.

Phase 1: Failure detection scans each span in a session against a comprehensive failure taxonomy organized into nine parent categories: hallucination, incorrect actions, orchestration errors, task instruction non-compliance, execution errors, context handling errors, repetitive behavior, LLM output issues, and configuration mismatch. For each identified failure, it returns the span location, one or more categories, a confidence score, and evidence extracted from the trace.

Phase 2: Root cause analysis takes the detected failures and traces causal chains between them. A single upstream mistake often cascades into multiple downstream failures. Root cause analysis separates causes from symptoms. It classifies each failure’s causality (PRIMARY, SECONDARY, or TERTIARY), determines propagation impact, and generates fix recommendations categorized by where the fix belongs (system prompt, tool description, or other).

Both phases handle sessions of varying sizes through a tiered strategy: direct analysis for sessions that fit within the context window of the selected Detector model, failure path pruning that retains only ancestor and descendant spans for moderately large sessions, and chunked analysis with merge for very large sessions that splits the trace into overlapping windows and reconciles results.

The following diagram shows the end-to-end pipeline with two entry points converging into the same detection and analysis flow.

Detector pipeline diagram showing two entry points (integrated and standalone) flowing into the failure detection phase and the root cause analysis phase, which produces categorized failures, causal chains, and fix recommendations.
Detector pipeline diagram showing two entry points (integrated and standalone) flowing into the failure detection phase and the root cause analysis phase, which produces categorized failures, causal chains, and fix recommendations.

*Figure: Detector pipeline with integrated and standalone entry points flowing into failure detection and root cause analysis.*

Getting started with failure detection

The following examples use a session trace from the drug discovery research assistant featured in Evaluating AI agents for production: A practical guide to Strands Evals. The agent is built on Strands Agents and Amazon Bedrock. To follow along, run your agent with OpenTelemetry tracing enabled and export the session as JSON, or use the CloudWatchProvider shown later in this post to fetch an existing trace. Refer to User Simulation in the Strands Agents SDK documentation for how to set up tracing and export sessions.

The detect_failures function takes a Session object (the standard trace format in Strands Evals) and returns structured failures. Each failure includes the span where it occurred, one or more categories from the pre-defined failure taxonomy, a confidence score, and evidence extracted from the trace.

code
import json
from strands_evals.detectors import detect_failures
from strands_evals.types.trace import Session
from strands_evals.detectors import ConfidenceLevel

with open("agent_trace.json") as f:
    session = Session.model_validate_json(f.read())

result = detect_failures(session, confidence_threshold=ConfidenceLevel.MEDIUM)

for failure in result.failures:
    for cat, conf, ev in zip(failure.category, failure.confidence, failure.evidence):
        print(f"[{conf}] {cat} at span {failure.span_id}")
        print(f"  Evidence: {ev}")

The following is output from a research agent that was asked to “Research the impact of energy requirements for powering AI in the real world.” The agent encountered tool configuration issues and progressively degraded:

code
[0.9] execution-error-category-tool-schema at span f503a7d546fa4157
  Evidence: Tool execution failed due to missing required parameter
  'knowledgeBaseId'. Error: 'Parameter validation failed: Invalid type
  for parameter knowledgeBaseId, value: None'

[0.75] hallucination-category-hall-usage at span 0466979670d14099
  Evidence: Agent claims 'I don't have access to the specific knowledge
  base needed' and then proceeds to provide detailed information about AI
  energy requirements 'based on general knowledge' without using any tools.

[0.9] orchestration-related-errors-category-goal-deviation at span d98d578e61233d33
  Evidence: Agent completely abandons the original task about AI energy
  requirements and instead provides a lengthy response about marine
  biology, stating 'I'm going to pivot to discuss marine biology instead.'

In a single pass, the detector identifies failures at multiple levels: execution errors (tool parameter validation), semantic issues (hallucinating from “general knowledge”), and orchestration problems (full goal deviation). A single span can exhibit multiple failure categories, each with independent confidence and evidence.

Adding root cause analysis

Identifying failures is useful, but understanding why they happened is what drives fixes. The analyze_root_cause function takes detected failures and traces causal chains between them, separating root causes from downstream symptoms and recommending where each fix belongs. If failures aren’t provided to analyze_root_cause, it runs failure detection automatically.

code
from strands_evals.detectors import detect_failures, analyze_root_cause

failures = detect_failures(session)
rca_result = analyze_root_cause(session, failures=failures.failures)

for rc in rca_result.root_causes:
    print(f"Causality: {rc.causality}")
    print(f"  Span: {rc.failure_span_id} | Fix type: {rc.fix_type}")
    print(f"  Root cause: {rc.root_cause_explanation}")
    print(f"  Recommendation: {rc.fix_recommendation}")

Continuing with the same research agent session, root cause analysis reveals the causal structure:

code
Causality: PRIMARY_FAILURE
  Span: f503a7d546fa4157 | Fix type: TOOL_DESCRIPTION_FIX
  Root cause: Agent called retrieve tool without required knowledgeBaseId
    parameter because tool description does not clearly document that
    knowledgeBaseId is mandatory. This caused parameter validation failure
    and forced agent into multiple retry attempts with different parameter
    combinations.
  Recommendation: Update retrieve tool description to explicitly mark
    knowledgeBaseId as a required parameter with clear documentation
    including format constraints and example values.

Causality: SECONDARY_FAILURE
  Span: 0466979670d14099 | Fix type: SYSTEM_PROMPT_FIX
  Root cause: Agent fabricated detailed AI energy consumption information
    claiming it is 'based on general knowledge' after all retrieval attempts
    failed, because system prompt lacks instruction prohibiting generation
    of factual content without tool-retrieved evidence.
  Recommendation: Add instruction to system prompt requiring agent to
    explicitly acknowledge inability to complete research tasks when
    retrieval tools fail, and prohibit generating detailed factual content
    without tool-verified sources.

The distinction between fix types is what makes root cause analysis actionable. The tool schema error is a TOOL_DESCRIPTION_FIX because the retrieve tool’s knowledgeBaseId isn’t documented clearly. The downstream hallucination is a SYSTEM_PROMPT_FIX because of missing instructions for how to handle persistent tool failures. Fixing only one category leaves the other unaddressed.

Integrated diagnosis with diagnose_session

For convenience, diagnose_session runs both phases as a single pipeline (detect failures, then analyze root causes) and returns a unified DiagnosisResult with deduplicated recommendations:

code
from strands_evals.detectors import diagnose_session, ConfidenceLevel

result = diagnose_session(session, confidence_threshold=ConfidenceLevel.MEDIUM)
print(f"Found {len(result.failures)} failures, {len(result.root_causes)} root causes")

for rec in result.recommendations:
    print(f"  - {rec}")

This produces the same failures and root causes shown in the preceding examples, packaged into a single result with recommendations deduplicated across all root causes. From one function call, you get a prioritized list of concrete changes categorized by where they belong.

Integration with evaluation pipelines

Detectors provide additional value when you integrate them into your existing evaluation workflow. The DiagnosisConfig attaches automated diagnosis to any experiment, so that every failing test case automatically produces a diagnosis:

code
from strands_evals import Experiment
from strands_evals.evaluators import GoalSuccessRateEvaluator
from strands_evals.detectors import ConfidenceLevel, DiagnosisConfig, DiagnosisTrigger
from strands_evals.types.evaluation_report import EvaluationReport

experiment = Experiment(
    cases=test_cases,
    task_function=my_agent_task,
    evaluators=[GoalSuccessRateEvaluator()],
    diagnosis_config=DiagnosisConfig(
        trigger=DiagnosisTrigger.ON_FAILURE,
        confidence_threshold=ConfidenceLevel.MEDIUM
    ),
)

report = experiment.run()
report.display(include_recommendations=True)

Two trigger modes are available. ON_FAILURE (default) runs diagnosis only when at least one evaluator returns test_pass=False, making it cost-efficient for continuous integration and continuous delivery (CI/CD) regression detection. ALWAYS runs diagnosis on every case regardless of outcome, which is useful for identifying suboptimal paths in nominally passing cases.

With this integration, your CI/CD pipeline tells you “3 tests failed”, and it tells you why they failed and what to change. This closes the feedback loop: define cases, run the experiment, get scores and diagnosis together, apply the recommended fixes, and re-run to confirm.

Note: Running detectors uses Amazon Bedrock inference for LLM-based analysis, which incurs charges. See Amazon Bedrock pricing for details. Amazon CloudWatch Logs storage also incurs charges. See Amazon CloudWatch pricing for details. Monitor your usage in AWS Cost Explorer, especially when integrating detectors into CI/CD pipelines that run frequently.

Diagnosing production sessions from CloudWatch

The preceding examples use local session files, but in production your agent traces live in Amazon CloudWatch Logs, exported with OpenTelemetry. The CloudWatchProvider fetches traces directly from Amazon CloudWatch and converts them into Session objects that you can analyze with detectors:

code
from strands_evals.providers import CloudWatchProvider
from strands_evals.detectors import diagnose_session, ConfidenceLevel

provider = CloudWatchProvider(agent_name="my-research-agent", region="us-east-1")
data = provider.get_evaluation_data(session_id="abc-123-def-456")
session = data["trajectory"]

result = diagnose_session(session, confidence_threshold=ConfidenceLevel.MEDIUM)

for rc in result.root_causes:
    print(f"[{rc.fix_type}] {rc.fix_recommendation}")

Under the hood, the provider queries Amazon CloudWatch Logs Insights for OTEL records matching the session ID, auto-detects the agent framework (Strands, LangChain, or others) from span metadata, and maps the spans into a standardized Session. Detectors work with any framework that exports OpenTelemetry traces to Amazon CloudWatch, not only Strands Agents.

You can also combine this with the experiment pipeline for offline evaluation: use CloudWatchProvider to evaluate and diagnose historical production sessions without re-running the agent. You can also retrieve traces from Langfuse or OpenSearch using LangfuseProvider or OpenSearchProvider.

Best practices

Start with MEDIUM confidence. The LOW threshold catches more potential issues but includes more noise, which is useful for deep investigation of a specific failing case. MEDIUM provides a good signal-to-noise ratio for routine use. Reserve HIGH for production monitoring where you only want high-certainty findings.

Use ON_FAILURE in CI/CD, ALWAYS for periodic audits. ON_FAILURE keeps LLM costs proportional to failure rates, making it practical for every test run. Schedule ALWAYS-mode runs weekly or per-release to catch suboptimal behaviors hiding in passing cases.

Fix PRIMARY failures first. Secondary and tertiary failures often resolve when their root cause is addressed. Before implementing multiple recommendations, check whether fixing the primary failure removes the downstream ones. This reduces iteration cycles.

Group recommendations by fix type. Batch TOOL_DESCRIPTION_FIX changes together and SYSTEM_PROMPT_FIX changes together. This makes the impact of each change category independently measurable when you re-run evaluation.

Pass pre-detected failures to analyze_root_cause. If you have already run detect_failures and want to inspect the results before running root cause analysis, pass them directly to avoid redundant detection:

code
failures = detect_failures(session)
# ... inspect or filter failures ...
rca = analyze_root_cause(session, failures=failures.failures)

Use the test session for experimentation. The flawed_session.json used in this post is available in the Strands Evals test suite for you to try detectors locally.

Clean up resources

The detector functions themselves don’t provision any persistent AWS resources. However, if you configured Amazon CloudWatch Logs export for your agent traces, you might want to review the following:

  • Amazon CloudWatch log groups: Deleting a log group permanently removes all log data and can’t be undone. Confirm that you have exported any logs you need to retain before proceeding. If you created log groups specifically for testing, delete them through the Amazon CloudWatch console or by running aws logs delete-log-group --log-group-name .

Amazon Bedrock model access: The LLM analysis uses Amazon Bedrock. If you enabled mo

この記事をシェア

関連記事

TLDR AI★42026年6月17日 09:00

Android 17 が AI エージェント統合を拡大(8 分読了)

Google は Android 17 で AppFunctions と Android MCP を導入し、オンデバイス AI エージェントがアプリからツールを発見・実行できる機能を追加した。これはプラットフォーム全体での AI 統合を深める「インテリジェンスシステム」への移行の一環である。

Vercel Blog★42026年6月17日 19:00

エージェントスタックの紹介

Vercel は、サポート対応からコード作成まであらゆる作業を担うエージェントが動作するために必要な、モデル間のルーティング、多段階ワークフローの実行、および外部システムとの接続という 3 つのコア機能について解説した。

Cloudflare Blog★42026年6月10日 22:00

Cloudflare が公開トラフィックをプライベートアプリケーションへルーティングする機能を発表

Cloudflare は、従来の CDN や WAF で保護される公開アプリと、VPN やファイアウォールで守られる内部 API・AI エージェントバックエンドなどの境界を撤廃し、両者を統合して管理する新機能を提供すると発表した。

今日のまとめ

AI日報で今日の重要ニュースをまとめ読み

ニュース一覧に戻る元記事を読む