Amazon Bedrock、エージェント型検索機能を追加
AWS は、従来の単一クエリ検索の限界を克服し、複雑な比較・分析タスクに対応する「Agentic Retrieval」機能を Amazon Bedrock Managed Knowledge Bases に導入した。
キーポイント
シングルショット検索の限界
複数の意図や時間軸にわたる質問に対し、単一の埋め込みベクトルでは文脈が欠落し、関連性の低い結果や偏ったクラスタリングしか得られない問題点を指摘。
エージェント型検索の自動化
人間の分析家が質問を分解・再検索・合成するプロセスを API で自動化し、複数の意図を持つクエリに対して計画と反復的な検索を実行可能にした。
AgenticRetrieveStream の実装
単一の呼び出しで検索の計画から回答生成までを行い、リクエスト構築やトレース解析を可能にする新しい API 仕様と、従来の Retrieve API との使い分け基準を提示。
ストリーミング処理によるリアルタイム追跡
レスポンスストリームからイベントを逐次解析し、Retrievalステップの抽出結果プレビューと最終生成テキストを順次出力することで、Agentic Retrieval の内部動作を可視化します。
Trace Event を活用した詳細なデバッグ
traceEvent イベントからステップ名やステータス、および検索結果のコンテンツテキストを取得し、システムがどの段階で処理を行っているかを明確に把握できます。
マルチKBルーティングと記述の重要性
最大5つのManaged KBを一度に指定でき、各KBへの自然言語説明がプランナーによるルーティングの基準となるため、明確な記述が不可欠です。
API選定とコスト構造
単一検索で済む質問には低コスト・高速な'Retrieve'を、複雑な多段質問や複数KB横断には高コストだが高精度な'AgenticRetrieveStream'を使用し、コストはトークン数ではなく反復回数(iterations)で計画する必要があります。
重要な引用
Agentic retrieval plans and iterates over retrieval and can generate a response in the same call.
A multi-intent question has no single point in embedding space that represents it well, so top-k chunks come back as an average of competing sub-intents.
if attrs.get("step") == "Retrieval":
print(f" {preview}")
The descriptions are the contract the planner routes on, so write each as a one-sentence pitch for its KB. Vague descriptions lead to vague routing.
Plan costs by iterations, not by tokens alone. Iterations drive both cost and wall-clock latency.
影響分析・編集コメントを表示
影響分析
この機能の導入は、RAG システムが単なる情報検索から、複雑な推論と意思決定支援へと進化することを示す重要な転換点です。企業は、より多層的で文脈に依存する質問に対して、高精度かつ迅速な回答を生成できるようになり、アナリストの業務効率化や意思決定の質向上に直結します。
編集コメント
単なる検索精度の向上ではなく、AI エージェントが自律的に思考プロセス(計画・反復)を構築する「Agentic AI」の実用化事例として注目すべき記事です。複雑なビジネス課題に対する LLM の応用力を飛躍的に高める技術的マイルストーンと言えます。
ユーザーは、PDF やスライド、サポートチケット、通話記録、ウェブコンテンツなど複数の情報源にまたがる多段階・比較・探索型の質問を投げかけます。従来の単発検索(single-shot retrieval)ではこうした質問に対応できず、回答が文脈を欠き、サポートチケットの対応がエスカレートし、アナリストが何時間も再検索に費やすという問題が生じます。
Amazon Bedrock Managed Knowledge Bases における「エージェント型検索(Agentic retrieval)」は、まさにこうした質問を想定して設計されています。
例えば、アナリストが以下のような質問をしたとしましょう。「2020 年と 2023 年の戦略を比較し、何が変わったのか?」や「製品ライン全体で最も大きなリスクは何か?これら 3 つを挙げてください。」いずれも単発の検索では対応できません。多様な意図を含む質問には、埋め込み空間(embedding space)上でそれを適切に表す単一の点が存在しないため、上位 k 件のチャンク(chunk)が競合する部分意図の平均的な結果として返されてしまいます。
エージェント型検索は、検索計画を立てて反復処理を行いながら、同じ呼び出し内で回答を生成します。本稿では、なぜ従来の検索が多段階質問で不十分なのか、また AgenticRetrieveStream API の仕組み(リクエスト構築とトレース解析を含む)について解説し、標準的な Retrieve API と比較していつこの機能を選ぶべきかを説明します。
単発検索が抱える課題
具体的な事例を通じて、そのギャップを明確にしましょう。Amazon の株主書簡を 25 年分取り込んで Managed Knowledge Base に格納したと仮定します。最初の質問は直接的です。
*「文書の中で最も重要なメッセージは何ですか?」*
標準的な Retrieve API は、ハイブリッドスコアに基づいて 5 つのチャンクを返します。テスト用コーパスでは、上位の結果はスコアが高いものの実質的な価値が低く、Amazon のロゴカラーリングに関する内容でした。続くチャンクには採用、ビルダー、差別化についての記事が含まれていますが、検索エンジン自体はクエリ埋め込みとの類似度に基づいて正しくランク付けしています。
しかし、「最も重要なメッセージ」という問いかけは曖昧すぎて、スコアリングアルゴリズムが何を重視すべきかの手がかりを持っていません。
では、より現実的な質問に昇格してみましょう。
*「2020 年と 2023 年の Amazon の採用、長期投資、顧客への執着に関する記述を比較し、重点のシフトはどこにあったか?」*
単一の検索クエリでこれに応えるには、2 つの時期にわたる 3 つの意図を同時に満たす必要があります。結果として得られるのは、関連性の薄いチャンクが散らばったものか、最も強い信号に支配された緊密なクラスタのどちらかです。どちらも、人間のアナリストが行うような分析ではありません。
人間のアナリストならどうするか
人間は質問を分解します。まず 2020 年の採用について検索し、次に 2023 年、そして各年度の投資哲学を検索します。結果を読み込み、不足している点に気づいて検索を改良し、再度実行します。十分な証拠を揃えた上で、ようやく統合的な結論を導き出します。
アジェンティック・リトリーブ(Agentic retrieval)は、この一連のワークフローを API として自動化するものです。
シングルショット検索が残した課題
- 多段階の質問:単一の埋め込みベクトルでは、複数の意図を含むクエリを適切に表現できません。その結果、上位 k 件の結果が異なる意図を混在させてしまう傾向があります。
- 比較推論:「次元 X における A と B の比較」のように、個々の項目ごとにターゲットを絞った検索が必要であり、単一の統合された検索では対応できません。
- 複数ソースにまたがる質問:根拠となる情報が複数のナレッジベースに分散している場合、静的なルーティングルールは脆く、クエリごとに柔軟に適応できない可能性があります。
- 情報の充足性:従来の検索手法には「これで十分か」を判断する機能がありません。常に k 件のチャンクを返すだけです。
- 探索的検索:一部の質問では、最初の結果の内容に基づいて追加の検索を行う必要がありますが、シングルショット検索は反復処理に対応していません。
これらの課題に対し、各チームは Retrieve API を基盤とした独自のエージェントフレームワークで対応しています。モデルに計画を立てさせ、ループ内で Retrieve API を呼び出し、サブクエリの管理や重複排除、終了判断を行わせる手法です。機能としては実現可能ですが、結果として各アプリケーションごとにカスタムな実装(パイプライン)が必要となり、それぞれが独自のレイテンシ、コスト、信頼性のリスクを抱えることになります。
エージェント型検索とは
Amazon Bedrock のマネージドナレッジベースにおいて、新しい検索モードとして「エージェント型検索(Agentic Retrieval)」が導入されました。これは AgenticRetrieveStream API を通じて利用可能です。
従来の単一の類似度検索ではなく、基盤モデルによって駆動される計画ループを実行します。モデルは質問を分解し、各部分に対して個別に検索を行います。さらに、必要な証拠が揃っているかを判断し、必要に応じて反復処理を繰り返します。デフォルトでは、この一連の処理を通じて根拠に基づいた回答を生成して返却します。
もし回答の生成を行わず、検索結果のみを取得したい場合は、generateResponse=False を設定してください。

このループの各ステップは、順序立てられたトレースイベントのストリームとして確認できます。各イベントには「ステップ」と「ステータス」が含まれているため、プランナーが何を行い、なぜその行動をとったのかを明確に把握することが可能です。
- SpeculativeRetrieval(予測的検索):最初の計画ステップを実行する前に走査される初期検索です。これにより、エンドツーエンドのレイテンシを削減できます。単一の KB の場合は生のユーザークエリを使用し、複数の KB の場合はサブクエリをルーティングするためのプローブ検索として機能します。この処理は maxAgentIteration のカウントには含まれません。
- Planning(計画):基盤モデル(FM)がクエリを分析し、過去の結果を確認した上で、検索可能な意図に合致するサブクエリを生成します。各反復の間では、このステップで回答の十分性を判断し、停止するか再度検索を行うかを決定します。
- Retrieval or FullDocumentExpansion(検索または全文書拡張):各サブクエリの実行ごとに 1 イベントが発生し、それぞれに独自のステータスが設定されます。アジェンティック・リトリーバルでは、エージェントが現在の文脈情報だけでは回答が不十分と判断した場合、このアクションで完全なドキュメントを取得できます。要約や要素のリスト化、あるいはドキュメント内の複数の箇所からの情報を必要とするクエリにおいて、この機能が特に有効です。追加のエビデンスが必要な場合はループが数回実行されますが、maxAgentIteration で上限が設定されています。
- Result(結果):最終イベントです。ここでは反復処理を通じて収集された重複除去済みのソースチャンクが含まれます。複数 KB へのリクエストの場合、各チャンクにはその取得元を示す sourceRetriever が明記されます。デフォルトで応答生成が有効になっているため、generateResponse=False を設定しない限り、結果イベントには根拠に基づいた回答と引用情報も含まれます。
重複除去とトレースに関する注釈
重複除去は最終的な結果イベントに対してのみ適用されます。複数のサブクエリが同じチャンクを取得した場合でも、そのチャンクは最終結果には一度だけ表示されます。一方、個々の計画ステップや検索ステップを確認するためのトレースイベントは引き続き利用可能です。
チューニングに寄与するパラメータは主に 2 つあります。
1 つ目は maxAgentIteration です。これは計画と検索の反復回数の上限を定義します。単一の KB を扱う場合は 3、複数の KB や比較クエリを扱う場合は 4〜5 を推奨しますが、プランナーが評価ステップで十分な証拠を検出すれば、それより早く終了することもあります。デフォルト値や最大値については Quotas and limits をご確認ください。
2 つ目は基盤モデルの設定です。foundationModelType フィールドは、エージェント検索でサービス管理モデルを使用するか、カスタムモデルを使用するかを決定します。CUSTOM に設定する場合は、foundationModelConfiguration 経由でモデルを指定してください。
料金に関する注意: エージェント検索は呼び出し単位で課金され、オーケストレーションに使用するモデルによって料率が決まります。サービス管理モデルを利用する場合、1,000 回のエージェント検索呼び出しあたり 4 ドルに加え、基盤となる Retrieve API の呼び出し 1,000 回あたり 1 ドルがかかります。Amazon Bedrock で利用可能なモデルを選択した場合は、そのモデルの標準的な転送価格(pass-through pricing)に、上記と同じく基盤となる Retrieve API の呼び出し 1,000 回あたり 1 ドルが加算されます。詳細は 料金ページ をご確認ください。
API の解説
計画ループの仕組みを確認したところで、次は AgenticRetrieveStream API の実際の使用例を見ていきましょう。
単一のナレッジベース
最も直接的なケースは、1 つの KB(ナレッジベース)に対して 1 つのクエリを送り、プランナーに分解させるパターンです。リクエストを送信してストリームを消費すると、トレースイベント、生成されたレスポンスチャンク(レスポンス生成が有効化されている場合)、そして最終結果イベントが順次配信されます。
import boto3
bedrock_agent_runtime = boto3.client(
"bedrock-agent-runtime",
region_name=REGION,
)
MODEL_ARN = (
"arn:aws:bedrock:us-west-2:"
":inference-profile/"
)
response = bedrock_agent_runtime.agentic_retrieve_stream(
messages=[{"role": "user", "content": {"text": QUERY}}],
retrievers=[
{
"configuration": {
"knowledgeBase": {
"knowledgeBaseId": KB_ID,
"retrievalOverrides": {
"maxNumberOfResults": 10,
},
}
}
}
],
agenticRetrieveConfiguration={
"foundationModelType": "CUSTOM",
"foundationModelConfiguration": {
"type": "BEDROCK_FOUNDATION_MODEL",
"bedrockFoundationModelConfiguration": {
"modelConfiguration": {
"modelArn": MODEL_ARN,
}
},
},
"maxAgentIteration": 3,
},
)必ず JSON 形式で返してください。translation フィールドのみを含め、他のフィールドは一切追加しないでください。余計なフィールドを追加しようとして本文がトークン上限に達し、出力が途中で切れてしまう事故を防ぐためです。
トレーシングイベント、生成されたレスポンスのチャンク、そして最終結果を消費する
for event in response["stream"]:
if "traceEvent" in event:
attrs = event["traceEvent"]["attributes"]
print(f"[TRACE] step={attrs.get('step')} status={attrs.get('status')}")
if attrs.get("step") == "Retrieval":
for chunk in attrs.get("retrievalResponse", []):
preview = chunk.get("content", {}).get("text", "")[:60]
print(f" {preview}")
elif "responseEvent" in event:
print(event["responseEvent"]["text"], end="", flush=True)
elif "result" in event:
print()
for chunk in event["result"].get("results", []):
source_retriever = chunk.get(
"sourceRetriever", {}
).get("identifier", "")
preview = chunk.get("content", {}).get("text", "")[:80]
print(f"[RESULT] {source_retriever} | {preview}")
このループが全体像です。1 つのリクエストで、オーケストレーションコードは不要で、上から順にストリームを読み取るだけです。
トレーシングイベントからはプランナーの動作が見え、結果イベントからは重複を排除したチャンク群が得られます。
本番環境では、これらのトレーシングイベントを Amazon CloudWatch にログ出力して、コストの属人性確認、レイテンシ予算の管理、デバッグに活用しましょう。
各イテレーションは 1 回のプランナー呼び出しとそのサブクエリによる検索処理を含むため、コストと実測時間(wall-clock latency)を決めるのはイテレーション回数です。
複数の知識ベース
マルチ KB ルーティングは、アジェンティック・リトリーバル(agent retrieval)が他の API では実現できない機能です。1 つのリクエストで最大 5 つの Managed KB リトライバーを登録し、それぞれに自然言語による説明を付与できます。プランナーはこの説明を読み取り、各サブクエリを最も関連性の高い知識ベースへルーティングします。
Amazon Bedrock の Managed Knowledge Base で「エージェント型検索」を活用する手法の続きです(10/14)。
以下のコードは、Bedrock Agent Runtime を使用してストリーミング形式でエージェント型検索を実行する例です。ユーザーからの質問を基に、複数の情報源から結果を取得します。
まず、messages パラメータには、ユーザーの問い合わせ(QUERY)を含めます。次に、retrievers 配列で検索対象となる知識ベースを定義します。ここでは2つのソースが設定されています。
1 つ目は「KB_PRODUCT_DOCS」です。これは公開されている製品ドキュメントや API リファレンスを含む情報源で、最大10件の結果を取得するように設定しています。
2 つ目は「KB_SUPPORT_TICKETS」です。こちらは解決済みの顧客サポートチケットや運用マニュアル(runbooks)を扱う情報源で、同様に最大10件まで取得します。
さらに、agenticRetrieveConfiguration パラメータでは、検索プロセスを制御する設定を行います。ここではカスタムモデル(CUSTOM)を使用し、Bedrock 上の特定の Foundation Model(MODEL_ARN で指定)を呼び出します。また、エージェントの反復処理回数の上限を5回に制限しています。
この構成により、単なるキーワードマッチングではなく、文脈を理解して複数の情報源から最適な回答を導き出す「エージェント型検索」が可能になります。
ストリームの受け取り方も同じです。ルーティングの判断結果はレスポンスに含まれ、各チャンクには sourceRetriever ID が付与されるため、どの KB がどのサブクエリを担当したかを追跡できます。プランナーがルーティングを行う際の契約条件となるのは説明部分なので、各 KB については「一言で伝える」ような簡潔な記述を心がけましょう。曖昧な説明は、結果として曖昧なルーティングにつながります。
適切な検索 API の選択
Managed Knowledge Bases では、2 つのクエリ表面(Retrieve と AgenticRetrieveStream)が用意されています。どちらを使うかは、質問の性質によって判断します。
Retrieve は、短く範囲が明確な質問や、単一の類似度検索で十分対応できる場合に適しています。プランナーを介さないため 1 回あたりのコストが最も低く、レイテンシも最小限に抑えられます。また、回答生成の制御は完全にユーザー側に委ねられます。
一方、AgenticRetrieveStream は、多段階の質問や比較・探索的な問い、あるいは複数の KB に跨る質問に対応するために使用します。この API は質問を分解し、意図ごとに検索を実行して情報の充足度を評価します。その結果、単一の検索では見逃す可能性のある根拠となる証拠を見つけ出し、同じ呼び出し内で grounding された回答を生成することも可能です。あるいは、チャンクを返却して、ユーザーが制御するモデルで合成させることもできます。複数のモデル呼び出しを行うためコストと時間がかかりますが、単一検索では得られない情報を引き出せるのが強みです。
| Feature | Retrieve | AgenticRetrieveStream |
|---|---|---|
| Output | 生チャンクと関連度スコア | デュプリケーション除去済みチャンク(ストリーミング)、オプションで grounding された回答 |
| Multi-KB support | なし | あり(最大 5 基まで) |
| Query decomposition | なし | あり |
ストリーミング対応
同期のみ
常時
ユーザークエリのサイズ(英語テキスト、文字数)
10,000
10,000
呼び出しあたりのファウンデーションモデルのコスト
なし
複数回の呼び出しが必要
レイテンシ
最低
最高
セルフマネージド KB(ベクトル型)
対応
非対応(Managed KB のみ)
関連性スコア
結果に直接表示
トレースイベント内のみ
再ランク付け(Reranking)
オプション
オプション(検索全体で 1 つのリランカーを使用)
ガードレール
対応
ブロックのみ(マスクは非対応)
エージェント型検索のベンチマーク結果
エージェント型検索を、多段階質問を対象とした公開ベンチマーク「MuSiQue (Trivedi et al., 2022)」で評価しました。その結果、単発の検索と比較して絶対的な再現率が 20% 向上し、特に最も難しい問題において大きな改善が見られました。一方、単一ステップの質問では、5 ポイント未満の小さな改善にとどまりました。
MuSiQue の各質問は、2 回から 4 回の検索ステップを必要するように設計されており、人間のアノテーターが回答に必要な正確な文書チェーンを特定しています。このチェーンは「オラクル分解」と呼ばれ、評価のための理想的な検索計画の基準となります。
質問の複雑さ | エージェント型検索による改善幅 (Δ) | 平均エージェントステップ数
---|---|---
2 段階質問 | +22.8 | 1.98
3 段階質問 | +31.9 | 3.50
4 ホップの質問
+37.3
4.78
2 つのパターンが際立っています。まず、質問が難解になるほど、成果の向上幅が大きくなります。回答に必要なステップ数が増えるほど、単一の検索では見逃す情報が多くなり、その分、エージェント型リトリバル(Agentic Retrieval)による回復効果も大きくなるのです。複数の手順を要する質問は、一度の検索で答えること自体が不可能です。
2 つ目は、システムが実行するステップ数が、実際に必要な数とほぼ一致している点です。ベンチマークでは各質問に対する理想のステップ数(人間のエキスパートが辿った連鎖)が示されていますが、エージェント型リトリバルの実行ステップ数は、その理想値からおよそ 1 つの範囲内に収まっています。つまり、行き当たりばったりになることなく、必要な情報を十分に検索して回答を導き出しているのです。
例
MuSiQue データセットにおける 4 ホップのクエリを、エージェント型リトリバルがどのように解決するかを示します。
クエリ:*"Explorer が Study in Brown の所属するレコードレーベルの一部となったグループの本拠地(headquarters location)に到達したのはいつか?"*
エージェント型リトリバルの実行トレース:
ホップ
取得されたゴールドドキュメント(概要)
0
Study in Brown
1
Emarcy Records
2
The Right Stuff Records
3
**
4
Santa Monica California
このリトリバルプロセスを、コーパス表現空間における t-SNE プロットを用いて可視化しました。これは、単一ステップでの検索結果(点線の赤い境界で囲まれた領域)と、多段階のエージェント型リトリバルの結果を比較したものです。各ホップにおいて、エージェント型リトリバルはクエリを分解して処理し、最終的に回答を含むドキュメントに到達します。

運用上のベストプラクティス
これらの実践は、コスト削減とレイテンシの短縮を実現し、本番環境におけるエージェント型検索の予測可能性を高めるために役立ちます。
- まず、小さく高速なプランナーモデルから始めましょう。エージェント型検索では多数の短い呼び出しが発生するため、大規模なプランナーモデルを使用してもレイテンシの観点からメリットが薄れることが多いです。
maxAgentIteration(最大エージェント反復回数)は対象範囲に応じて設定してください。単一の知識ベースの場合は 3、複数の知識ベースを扱う場合は 4〜5 が目安です。まずは計測し、その結果に基づいて調整しましょう。- リトライバーの説明は、製品マーケティングの文書のように記述します。具体的で明確な表現を用い、他との差別化を図ってください。
- トレース(追跡情報)をストリーミングして Amazon CloudWatch Logs に出力し、リクエストごとに相関 ID を付与してください。これにより、再現テストやデバッグが容易になります。
- コスト計画はトークン数だけでなく、反復回数に基づいて行いましょう。コストと実際の経過時間(ウォールクロックタイム)の両方に影響を与えるのは反復回数です。
原文を表示
Your users ask multi-part, comparative, and exploratory questions that span PDFs, slides, tickets, transcripts, and web content. Classic single-shot retrieval breaks down on these questions. Answers miss context, support tickets escalate, and analysts waste hours re-running searches. Agentic retrieval for Amazon Bedrock Managed Knowledge Bases is designed for these questions.
Consider two questions an analyst might ask: “Compare our 2020 and 2023 strategy. What changed?” and “What are the three biggest risks across product lines?” Neither is a single-shot lookup. A multi-intent question has no single point in embedding space that represents it well, so top-k chunks come back as an average of competing sub-intents.
Agentic retrieval plans and iterates over retrieval and can generate a response in the same call. This post focuses on why classic retrieval falls short on multi-part questions, how the AgenticRetrieveStream API works (including request construction and trace parsing), and when to choose it over the standard Retrieve API.
Why single-shot retrieval falls short
A worked example makes the gap concrete. Suppose you have ingested 25 years of Amazon shareholder letters into a Managed Knowledge Base. Your first question is direct:
*“What is the most important message in the documents?”*
The standard Retrieve API returns five chunks by hybrid score. In our test corpus, the top result is high-scoring but low-value: it covers the Amazon logo color scheme. The following chunks cover hiring, builders, and differentiation. The retriever did its job and ranked by similarity to the query embedding. But “*most important message*” is vague, and the scorer has no signal for what matters.
Now escalate to a realistic question:
*“Compare how Amazon talked about hiring, long-term investment, and customer obsession in 2020 vs 2023. Where did emphasis shift?”*
Single-shot retrieval must now serve three intents across two time periods with one query vector. You get one of two outcomes: a scatter of loosely related chunks, or a tight cluster dominated by the strongest signal. Neither is what a human analyst would do.
What a human analyst would do
A human would decompose the question. They would search hiring in 2020, then hiring in 2023, then investment philosophy in each year. They would read the results, notice gaps, refine the search, and run it again. With enough evidence in hand, they would synthesize.
Agentic retrieval automates this workflow as an API.
Gaps left by single-shot retrieval
- Multi-part questions: A single embedding may not represent a multi-intent query well, so top-k results tend to blend intents together.
- Comparative reasoning: “Compare A and B across dimension X” requires targeted retrieval per item, not one blended search.
- Cross-source questions: When evidence spans multiple knowledge bases, static routing rules are brittle and might not adapt well per query.
- Sufficiency: Classic retrieval doesn’t judge “enough.” It returns k chunks regardless.
- Exploration: Some questions need follow-up searches based on what the first results reveal. Single-shot retrieval can’t iterate.
Teams have addressed this gap with custom agent frameworks built on the Retrieve API. They prompt a model to plan and call Retrieve API in a loop, manage sub-queries, deduplicate, and decide when to stop. It works, but it becomes custom plumbing in every application, each instance carrying its own latency, cost, and reliability risks.
What agentic retrieval is
Agentic retrieval is a new retrieval mode in Amazon Bedrock Managed Knowledge Bases, available through the AgenticRetrieveStream API. Instead of one similarity search, it runs a planning loop driven by a foundation model: the model decomposes your question, retrieves against each part, judges whether it has enough evidence, and iterates as needed. It generates a grounded response by default in the same call. Set generateResponse=False to return retrieval results without generating a response.

You see every step of that loop as an ordered stream of trace events. Each event carries a step and a status, so you can see what the planner did and why:
- SpeculativeRetrieval: An initial retrieval that runs before the first planning step to reduce end-to-end latency. With a single KB, it uses the raw user query. With multiple KBs, it is a probe search used to route sub-queries. It doesn’t count toward maxAgentIteration.
- Planning: The foundation model (FM) analyzes the query, reviews prior results, and emits sub-queries aligned to retrievable intents. Between iterations, this is also where the model judges sufficiency and decides whether to stop or search again.
- Retrieval or FullDocumentExpansion: One event per sub-query execution, each with its own status. In agentic retrieval, this action/event can fetch a full document if the agent determines that the passage context is insufficient to answer the query. Often, queries that require summarization, listing elements, or information from various parts of a document benefit from this action. The loop may run several iterations if more evidence is needed, bounded by maxAgentIteration.
- Result: The final event. It contains the deduplicated source chunks collected across the iterations. For multi-KB requests, each chunk identifies its sourceRetriever. Because response generation is enabled by default, the result event also contains the grounded answer and citations unless you set generateResponse=False.
A note on deduplication and the trace. Deduplication applies only to the final result event. When multiple sub-queries retrieve the same chunk, that chunk appears only once in the final results. Trace events remain available for reviewing the individual planning and retrieval steps.
Two parameters do most of the tuning. The first is maxAgentIteration, the ceiling on planning-plus-retrieval iterations. Use 3 for a single KB and 4–5 for multi-KB or comparative queries, though the planner may exit early after its evaluation step finds the evidence sufficient. See Quotas and limits for defaults and maximums.
The second is the foundation model configuration. The foundationModelType field determines whether agentic retrieval uses the service-managed model or a custom model. When you set it to CUSTOM, provide the model through foundationModelConfiguration.
Note on pricing: Agentic retrieval is priced per call, and the model you choose for the orchestration sets the rate. With the managed model, you pay $4 per 1,000 agentic retrieval calls plus $1 per 1,000 underlying Retrieve API calls. If you choose a model available in Amazon Bedrock, you pay standard pass-through Bedrock pricing for that model plus the same $1 per 1,000 underlying Retrieve calls. See more details on the pricing page.
API walkthrough
Now that you have seen how the planning loop works, we examine the AgenticRetrieveStream API in practice.
Single knowledge base
The most direct case: one KB, one query, let the planner decompose. You send the request, then consume the stream, which delivers trace events, generated-response chunks when response generation is enabled, and a final result event.
import boto3
bedrock_agent_runtime = boto3.client(
"bedrock-agent-runtime",
region_name=REGION,
)
MODEL_ARN = (
"arn:aws:bedrock:us-west-2:"
":inference-profile/"
)
response = bedrock_agent_runtime.agentic_retrieve_stream(
messages=[{"role": "user", "content": {"text": QUERY}}],
retrievers=[
{
"configuration": {
"knowledgeBase": {
"knowledgeBaseId": KB_ID,
"retrievalOverrides": {
"maxNumberOfResults": 10,
},
}
}
}
],
agenticRetrieveConfiguration={
"foundationModelType": "CUSTOM",
"foundationModelConfiguration": {
"type": "BEDROCK_FOUNDATION_MODEL",
"bedrockFoundationModelConfiguration": {
"modelConfiguration": {
"modelArn": MODEL_ARN,
}
},
},
"maxAgentIteration": 3,
},
)
# Consume trace events, generated-response chunks, and the final result
for event in response["stream"]:
if "traceEvent" in event:
attrs = event["traceEvent"]["attributes"]
print(f"[TRACE] step={attrs.get('step')} status={attrs.get('status')}")
if attrs.get("step") == "Retrieval":
for chunk in attrs.get("retrievalResponse", []):
preview = chunk.get("content", {}).get("text", "")[:60]
print(f" {preview}")
elif "responseEvent" in event:
print(event["responseEvent"]["text"], end="", flush=True)
elif "result" in event:
print()
for chunk in event["result"].get("results", []):
source_retriever = chunk.get(
"sourceRetriever", {}
).get("identifier", "")
preview = chunk.get("content", {}).get("text", "")[:80]
print(f"[RESULT] {source_retriever} | {preview}")That is the whole loop: one request, no orchestration code, and a stream you read top to bottom. The trace events tell you what the planner did. The result event gives you the deduplicated chunks. In production, log these trace events to Amazon CloudWatch for cost attribution, latency budgeting, and debugging. Each iteration is one planner invocation plus its sub-query retrievals, so the number of iterations is what drives both cost and wall-clock latency.
Multiple knowledge bases
Multi-KB routing is what agentic retrieval does that the other APIs cannot. Register up to five Managed KB retrievers in one request and attach a natural-language description to each. The planner reads those descriptions to route each sub-query to the most relevant KB.
response = bedrock_agent_runtime.agentic_retrieve_stream(
messages=[{"role": "user", "content": {"text": QUERY}}],
retrievers=[
{
"configuration": {
"knowledgeBase": {
"knowledgeBaseId": KB_PRODUCT_DOCS,
"retrievalOverrides": {
"maxNumberOfResults": 10,
},
}
},
"description": "Public product documentation and API reference.",
},
{
"configuration": {
"knowledgeBase": {
"knowledgeBaseId": KB_SUPPORT_TICKETS,
"retrievalOverrides": {
"maxNumberOfResults": 10,
},
}
},
"description": "Resolved customer support tickets and runbooks.",
},
],
agenticRetrieveConfiguration={
"foundationModelType": "CUSTOM",
"foundationModelConfiguration": {
"type": "BEDROCK_FOUNDATION_MODEL",
"bedrockFoundationModelConfiguration": {
"modelConfiguration": {
"modelArn": MODEL_ARN,
}
},
},
"maxAgentIteration": 5,
},
)You consume the stream the same way. The routing decision shows up in the result: each chunk carries a sourceRetriever ID, so you can see which KB answered which sub-query. The descriptions are the contract the planner routes on, so write each as a one-sentence pitch for its KB. Vague descriptions lead to vague routing.
Choosing the right retrieval API
Managed Knowledge Bases give you two query surfaces: Retrieve and AgenticRetrieveStream. You pick based on the shape of the question.
Use Retrieve for short, well-scoped questions where one similarity search is enough. It has no planner, the lowest cost per call, and the tightest latency, and you keep full control over how you generate an answer.
Use AgenticRetrieveStream when questions are multi-part, comparative, exploratory, or span multiple knowledge bases. It decomposes the question, retrieves per intent, evaluates sufficiency, and can generate a grounded response in the same call, or return chunks for you to synthesize with a model you control. It costs more and takes longer because it makes multiple model calls, but it finds evidence a single search can miss.
Feature
Retrieve
AgenticRetrieveStream
Output
Raw chunks + relevance scores
Deduplicated chunks (streaming), optional grounded answer
Multi-KB support
No
Yes, up to 5.
Query decomposition
No
Yes
Streaming
Sync only
Always
User query size, English text (characters)
10,000
10,000
Foundation model cost per call
None
Multiple invocations
Latency
Lowest
Highest
Self-Managed KB (VECTOR)
Yes
No (Managed KB only)
Relevance scores
In results directly
In trace events only
Reranking
Optional
Optional (one reranker across retrievers)
Guardrails
Supported
BLOCK only (MASK unsupported)
How agentic retrieval performs on benchmarks
We evaluated agentic retrieval on MuSiQue (Trivedi et al., 2022), a public benchmark of multi-hop questions. On these questions it showed 20 percent absolute recall improvement over single-shot retrieval, with the largest gains on the hardest questions. Single-hop questions show smaller gains (under five points).
Each MuSiQue question is designed to require two, three, or four retrieval steps, and a human annotator identified the exact document chain needed to answer it. That chain is an oracle decomposition: the ideal retrieval plan to measure against.
Question Complexity
Δ (Gain) with Agentic Retrieve
Agentic Hops (avg)
2-hop questions
+22.8
1.98
3-hop questions
+31.9
3.50
4-hop questions
+37.3
4.78
Two patterns stand out. First, the harder the question, the bigger the gain. The more steps a question requires, the more a single search misses, and the more agentic retrieval recovers. Questions that need several steps simply cannot be answered in one pass.
Second, the system takes about as many steps as the question actually needs. The benchmark tells us the ideal number of steps for each question (the chain a human expert traced). Agentic retrieval’s own number of steps stays within roughly one of that ideal, so it searches enough to answer the question without wandering.
Example
We demonstrate how agentic retrieval solves a 4-hop query in the MuSiQue dataset.
Query: *“When did the explorer reach the headquarters location of the group Study in Brown’s record label is part of?”*
Agentic Retrieve Trace:
Hop
Retrieved Gold Documents (about)
0
Study in Brown
1
Emarcy Records
2
The Right Stuff Records
3
**
4
Santa Monica California
We illustrate the retrieval process using the following t-SNE plot over the corpus representation space. It shows how single-step Retrieve results (dotted-red boundary) compare to multi-step agentic retrieve. In each hop, agentic retrieve breaks down the query. It arrives at the document containing the answer.

Best practices
These practices reduce cost, improve latency, and keep agentic retrieval predictable in production.
- Start with a small, fast planner model. Agentic retrieval makes many short calls. A large planner rarely justifies the latency.
- Set maxAgentIteration based on scope. Use 3 for single-KB, 4–5 for multi-KB. Measure, then tune.
- Write retriever descriptions like product marketing. Be specific, concrete, and distinctive.
- Stream the trace to Amazon CloudWatch Logs with a correlation ID per request. This supports replay and debug.
- Plan costs by iterations, not by tokens alone. Iterations drive both cost and wall-clock latency.
Combine with
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み