Amazon Bedrock 知识库支持单次与智能体式检索

一位银行运营员工早上上班时,先向内部 AI 助手询问开立企业账户需要哪些文件。答案就在一份清单里。几个小时后,同一位员工又问,这些要求在个人独资企业、LLC 和有多名所有者的合伙企业之间有何不同。这个答案分散在几份政策指南中。同一个助手必须同时处理这两个问题:第一个要快、要便宜,第二个要彻底。应用需要一种方式,让检索投入与每个请求相匹配,而不必为简单问题和复杂问题分别搭建系统。
Amazon Bedrock Managed Knowledge Base 现在通过 AgenticRetrieveStream 支持单次 RAG(检索增强生成,RAG)和仅检索请求。使用单次 RAG 时,该服务只搜索一次你的知识库,并用基础模型(FM)根据找到的段落生成答案。对于仅检索请求,服务会返回匹配的段落而不生成答案,这样你的应用或用户可以直接处理源文本。这些模式与现有的智能体式检索并存——在智能体式检索中,服务会先规划并执行多次搜索,然后再作答。现在,员工这两个问题都可以用同一个 API:清单查询用单次 RAG,跨政策比较用智能体式检索。
本文将解释这些新设置如何工作,以及何时使用每种模式。我们以一个示例性的内部银行政策助手为例,展示单次 RAG 如何处理直接问题,以及智能体式检索如何支持跨政策文档的比较。我们还会展示,当员工需要查看源段落而不是生成式答案时,如何配置仅检索请求。
智能体式检索能帮助助手回答需要不止一次搜索才能解决的问题。基础模型会把问题拆解为多个子查询,搜索相关的知识库,并评估检索结果是否提供了足够的信息来回答原始问题。如果发现信息缺口,它可以在配置的迭代上限内优化搜索并检索更多证据。
对于应用开发者而言,这带来了几项好处:
对于复杂问题,这些智能体式能力依然很有价值。而对于简单的查询,应用也需要一种无需额外规划即可完成检索和回答的方式。扩展后的 maxAgentIteration 取值范围填补了这一空白。只需一个参数,你就可以为每个请求选择三种模式之一:
单次 RAG(Single-shot RAG)只调用一次基础模型来生成答案,与智能体式检索相比,可以降低延迟和模型用量。仅检索请求则不调用基础模型。你可以针对每个请求在速度与答案质量之间取得平衡,而无需集成第二套 API,也无需为简单查询和复杂查询分别维护代码路径。
在逐一介绍这些新取值之前,先明确迭代次数是如何计算的会有所帮助,因为正是这一点让行为变得可预测。
一次迭代等于一次基础模型调用。循环总是以一次单独的答案生成调用结束。取值为 n 时,最多可进行 n 减 1 轮智能体式规划,最后一次迭代保留用于生成回答。每一轮规划都是一次查询重写加上一次检索。迭代次数越多,规划轮次越多,在难题上的效果也越好;迭代次数越少,延迟越低。
有一点不计入其中:预检索(speculative retrieval)。在第一个规划步骤之前先行执行的初始检索属于检索,而非一次迭代。它永远不会计入你的 maxAgentIteration 值,而且它只会让请求变得更快。在阅读下面这些取值时,请记住这一区别。
现在的取值范围是 0–5。
三种模式都支持多个知识库,包括 maxAgentIteration=0 和 1 的情况。单次检索并不意味着只有一个知识库。智能体模式增加了查询分解、证据评估和迭代搜索,而不是对多个知识库的独占访问。
这就是单次检索增强生成(RAG):一次检索,然后一个回答。没有智能体规划,没有查询重写。API 针对你的查询执行一次检索,并基于这些段落生成回答。这就是「检索一次,然后生成回答」的模式——此前无法通过这个 API 表达。
将其与 generateResponse=true 搭配使用,即可获得基于检索到的段落生成的回答。如果你只需要这些段落,请改用 maxAgentIteration=0,如下一节所述。
如果你的大部分流量都是范围明确、直截了当的问题,那么这很可能就是你想要的默认设置。
这会执行一次必定发生的检索,但不生成任何内容。不会调用任何基础模型。它等同于直接调用 Retrieve API。因此,它最适合那些已经统一使用 AgenticRetrieveStream 的调用方——他们宁愿改一个参数,也不愿切换 API。
由于没有调用大语言模型(LLM),也就没有可生成的回答。在该取值下设置 generateResponse=true 是无效的,会返回 4xx 错误,因为生成回答需要调用 LLM。
在智能体模式下,基础模型会把复杂问题拆解为多个聚焦的子查询,并分多步检索证据,包括跨多个知识库检索。它会评估检索到的信息,并在证据缺失时优化自身搜索。对于单次搜索可能无法完全解决的多部分问题和比较类问题,这种方式可以提升检索准确率。
启用响应生成后,数值 n 允许在基于检索到的证据生成答案之前,最多进行 n 减 1 轮规划。现有使用 2–5 之间数值的请求保持当前行为不变。
一种理解方式是:
数值越低,调用越快、越可预测。数值越高,规划器在面对真正困难的问题时就有越多空间进行拆解和优化。简单流量可以从低值起步;当复杂查询的准确率比延迟更重要时,再调高该值。
设想一家虚构的银行,其运营团队使用一个由知识库支撑的内部助手,知识库内容涵盖开户流程、文件清单和政策指南。员工借助该助手查找并理解银行有明文规定的各项要求。以下示例说明该应用如何为每个工作流选择检索模式。它们并不描述某个客户的实际部署或实测结果。
下图展示了该银行助手如何为每个请求选择检索模式。
图 1:该银行助手如何为每个请求选择检索模式
一名员工向助手提出问题。应用会选择一种检索模式,并把请求发送到 AgenticRetrieveStream。在单次检索增强生成(RAG)模式下,服务只检索一次知识库并生成答案。在智能体式检索模式下,服务会把问题拆分成若干部分,进行多次检索,然后生成带引用的答案。在仅检索模式下,服务返回源文段落,而不生成答案。以下各节将逐一说明每种模式。
一名员工问道:“个体经营者开立企业支票账户需要哪些文件?”在本例中,银行维护着一份载有答案的专用核对清单。应用设置 maxAgentIteration=1 和 generateResponse=true,以检索相关段落并生成回答,而不进行查询重写或智能体式规划。
这就是单次 RAG 模式:一次检索,随后一次答案生成调用。当问题与支撑内容已有明确范围时,它可以省去规划步骤。
另一名员工问道:“个体经营者和 LLC 的开户要求有何不同?按照我们的政策,非居民所有者是否适用额外核查,若适用,是哪些核查?”回答这个问题可能需要来自不同流程文档和所有权验证指南的信息。
对于这一工作流,应用可以设置 maxAgentIteration=4 和 generateResponse=true,从而在生成答案前最多进行三轮规划。规划器可以把问题拆分为子查询,检索相关证据,并在信息缺失时细化搜索。合适的迭代上限应当用有代表性的问题来评估,而不是想当然地认为数值越高答案就越好。
员工在审核开户流程时,可能想要相关的政策文本,而不是生成的摘要。该应用将 maxAgentIteration=0 和 generateResponse=false,以在不调用语言模型的情况下返回段落。随后,它可以显示这些段落及其来源引用,供员工查看。
原文较长,译文为节选;译文由英文原文机器翻译,术语按行业惯例统一,可在文末展开原文核对。
查看英文原文(Single-shot and agentic retrieval with Amazon Bedrock Managed Knowledge Base)
A banking operations employee starts the morning by asking an internal AI assistant which documents are needed to open a business account. The answer is in a single checklist. A few hours later, the same employee asks how those requirements differ across sole proprietorships, LLCs, and partnerships with multiple owners. That answer is spread across several policy guides. One assistant has to handle both questions, quickly and cheaply for the first and thoroughly for the second. Applications need a way to match retrieval effort to each request without building separate systems for simple and complex questions.
Amazon Bedrock Managed Knowledge Base now supports single-shot Retrieval Augmented Generation (RAG) and retrieval-only requests through AgenticRetrieveStream. With single-shot RAG, the service searches your knowledge bases once and uses a foundation model (FM) to generate an answer from the passages it finds. With retrieval-only requests, the service returns the matching passages without generating an answer, so your application or the user can work with the source text directly. These modes join the existing agentic retrieval, where the service plans and runs multiple searches before answering. You can now use the same API for both of the employee’s questions: single-shot RAG for the checklist lookup and agentic retrieval for the cross-policy comparison.
In this post, we explain how the new settings work and when to use each mode. We use an illustrative internal banking policy assistant to show how single-shot RAG handles direct questions and how agentic retrieval supports comparisons across policy documents. We also show how to configure retrieval-only requests when an employee needs to review source passages rather than a generated answer.
Key benefits
Agentic retrieval helps an assistant answer questions that require more than one search. A foundation model breaks the question into sub-queries, searches the relevant knowledge bases, and evaluates whether the results provide enough information to answer the original question. If it identifies gaps, it can refine the search and retrieve additional evidence, within the configured iteration limit.
For application builders, this provides several benefits:
- Better support for multi-part questions – Targeted searches can find evidence for each part of a question instead of relying on one search to cover everything. In the banking example, the assistant can look up requirements for sole proprietors and LLCs separately before comparing them.
- Follow-up searches when information is missing – The planner can use what it finds to decide what to search for next. It can also retrieve a full document when a passage doesn’t provide enough context, helping address gaps that a single retrieval might leave unresolved.
- Answers with supporting evidence – When response generation is enabled, the service combines retrieved information into an answer with citations. Trace events show the planning and retrieval steps, helping developers inspect how the answer was produced.
- Less custom orchestration – The service manages the planning, retrieval, evaluation, and response-generation workflow through one API. Applications don’t need to implement their own loop to coordinate these steps.
These agentic capabilities remain valuable for complex questions. For straightforward lookups, applications also need a way to retrieve and answer without additional planning. The expanded maxAgentIteration range closes that gap. With one parameter, you can choose one of three modes for each request:
- Retrieval-only returns passages without generating an answer.
- Single-shot RAG retrieves once and generates an answer, with no planning rounds.
- Agentic retrieval plans and runs multiple searches for complex questions.
Single-shot RAG uses one foundation model call to generate the answer, which can reduce latency and model usage compared with agentic retrieval. Retrieval-only requests make no foundation model calls. You can balance speed and answer quality for each request, without integrating a second API or maintaining separate code paths for simple and complex queries.
How retrieval iterations are counted
Before walking through the new values, it helps to anchor on how iterations are counted, because that is what makes the behavior predictable.
One iteration equals one foundation model call. The loop always ends with a single answer-generation call. A value of n buys up to n minus 1 agentic planning rounds, with the last iteration reserved for generating the response. Each planning round is one query rewrite plus a retrieval. More iterations means more planning rounds and better results on hard questions. Fewer iterations means lower latency.
One thing that doesn’t count: speculative retrieval. The initial retrieval that runs ahead of the first planning step is retrieval, not an iteration. It never counts against your maxAgentIteration value, and it only ever makes a request faster. Keep that distinction in mind as you read the following values.
What’s new
The range is now 0–5.
All three modes support multiple knowledge bases, including maxAgentIteration=0 and 1. Single-shot retrieval doesn’t mean a single knowledge base. Agentic mode adds query decomposition, evidence evaluation, and iterative searches, rather than exclusive access to multiple knowledge bases.
maxAgentIteration = 1: Basic RAG (the headline use case)
This is single-shot RAG: one retrieval, then one answer. No agentic planning, no query rewriting. The API retrieves once against your query and generates a response grounded in those passages. This is the retrieve once, then generate a response pattern that previously wasn’t expressible through this API.
Pair it with generateResponse=true to get a generated answer grounded in the retrieved passages. If you only need the passages, use maxAgentIteration=0 instead, as described in the next section.
If most of your traffic is well-scoped, direct questions, this is likely the setting you want as a default.
maxAgentIteration = 0: Passages only, zero LLM calls
This runs one guaranteed retrieval and generates nothing. No foundation model is invoked. It is equivalent to calling the Retrieve API directly. This makes it most useful for callers who are already standardized on AgenticRetrieveStream and would rather change a parameter than switch APIs.
Because no large language model (LLM) is called, there is no answer to generate. Setting generateResponse=true at this value is invalid and returns a 4xx error, because generating an answer requires an LLM call.
maxAgentIteration = 2 to 5: Agentic mode, unchanged
In agentic mode, a foundation model breaks complex questions into focused sub-queries and retrieves evidence in multiple steps, including across multiple knowledge bases. It evaluates the retrieved information and can refine its searches when evidence is missing. This approach can improve retrieval accuracy for multi-part and comparative questions that a single search might not fully address.
With response generation enabled, a value of n allows up to n minus 1 planning rounds before generating an answer grounded in the retrieved evidence. Existing requests using values from 2–5 retain their current behavior.
Choosing a value
One way to reason about it:
maxAgentIteration |
What you get | Best for |
| 0 | One retrieval, no generation, zero LLM calls | Passage retrieval. Callers standardized on this API who want Retrieve-style behavior |
| 1 | One retrieval plus one answer | Single-shot RAG for direct, well-scoped questions |
| 2 to 5 | Up to n minus 1 planning rounds, then an answer | Multi-part, comparative, exploratory, and cross-knowledge-base questions |
The lower the value, the faster and more predictable the call. The higher the value, the more the planner can decompose and refine on genuinely hard questions. Start low for simple traffic, raise it when accuracy on complex queries matters more than latency.
In practice: An internal banking policy assistant
Consider a fictional bank whose operations team uses an internal assistant backed by a knowledge base of account-opening procedures, documentation checklists, and policy guides. Employees use the assistant to locate and understand the bank’s documented requirements. The following examples illustrate how the application can select a retrieval mode for each workflow. They don’t describe a customer deployment or measured results.
The following diagram shows how the banking assistant selects a retrieval mode for each request.
An employee asks the assistant a question. The application chooses a retrieval mode and sends the request to AgenticRetrieveStream. With single-shot RAG, the service searches the knowledge base once and generates an answer. With agentic retrieval, the service splits the question into parts, searches several times, and then generates an answer with citations. With retrieval-only, the service returns source passages without generating an answer. The following sections explain each mode.
Answer a direct documentation question
An employee asks, “What documents are required to open a business checking account for a sole proprietor?” In this example, the bank maintains a dedicated checklist that contains the answer. The application sets maxAgentIteration=1 and generateResponse=true to retrieve relevant passages and generate a response, without query rewriting or agentic planning.
This is the single-shot RAG pattern: one retrieval, followed by one answer-generation call. It avoids a planning step when the question and supporting content are already well scoped.
Compare requirements across policy documents
Another employee asks, “How do account-opening requirements differ for sole proprietors and LLCs, and what additional checks, if any, apply to nonresident owners under our policy?” Answering this question might require information from separate procedures and ownership-verification guides.
For this workflow, the application can set maxAgentIteration=4 and generateResponse=true, allowing up to three planning rounds before generating an answer. The planner can break the question into sub-queries, retrieve relevant evidence, and refine its search if information is missing. The appropriate iteration limit should be evaluated against representative questions rather than assuming that a higher value always produces a better answer.
Show source passages without generating an answer
An employee reviewing an account-opening procedure might want the relevant policy text instead of a generated summary. The application sets maxAgentIteration=0 and generateResponse=false to return passages with no language model calls. It can then display those passages and their source references for the employee to review.
All three workflows use AgenticRetrieveStream. The application chooses the iteration limit and whether to return a generated answer. Selecting the mode is application logic, not automatic routing provided by this parameter. The assistant supports policy lookup and comparison. It doesn’t approve accounts or replace the bank’s review and authorization processes.
Solution overview
The following example shows a complete agentic request. The sections after it adapt it for single-shot RAG and retrieval-only modes.
Select a retrieval mode for the banking assistant
The sample code demonstrates the three workflows using fictional policy documents.
{
"messages": [
{
"content": {
"text": "How do account-opening requirements differ for sole proprietors and LLCs, and what additional checks, if any, apply to nonresident owners under our policy?"
},
"role": "user"
}
],
"retrievers": [
{
"description": "Knowledge base of account-opening procedures, documentation checklists, and policy guides",
"configuration": {
"knowledgeBase": {
"knowledgeBaseId": "KB12345678"
}
}
}
],
"generateResponse": true,
"agenticRetrieveConfiguration": {
"foundationModelType": "MANAGED",
"rerankingModelType": "MANAGED",
"maxAgentIteration": 4
}
}
Example: Single-shot RAG
Setting up basic RAG is a one-line change from an agentic call. Set maxAgentIteration to 1 and keep response generation on.
{
"messages": [
{
"content": {
"text": "What documents are required to open a business checking account for a sole proprietor?"
},
"role": "user"
}
],
"retrievers": [
{
"description": "Knowledge base of account-opening procedures, documentation checklists, and policy guides",
"configuration": {
"knowledgeBase": {
"knowledgeBaseId": "KB12345678"
}
}
}
],
"generateResponse": true,
"agenticRetrieveConfiguration": {
"foundationModelType": "MANAGED",
"rerankingModelType": "MANAGED",
"maxAgentIteration": 1
}
}
You consume the stream the same way you always have. The difference is what’s in it: a single retrieval and one grounded answer, with no planning trace events in between.
Example: Passages only
For retrieval with no generation, set maxAgentIteration to 0. Response generation must be off at this value.
{
"messages": [
{
"content": {
"text": "Show the policy text for the business account-opening procedure."
},
"role": "user"
}
],
"retrievers": [
{
"description": "Knowledge base of account-opening procedures, documentation checklists, and policy guides",
"configuration": {
"knowledgeBase": {
"knowledgeBaseId": "KB12345678"
}
}
}
],
"generateResponse": false,
"agenticRetrieveConfiguration": {
"foundationModelType": "MANAGED",
"rerankingModelType": "MANAGED",
"maxAgentIteration": 0
}
}
This returns the deduplicated source passages with no generated answer. The retrieval behavior matches a direct Retrieve call, but the response format differs: passages arrive in the stream’s result event without score or location fields.
Conclusion
With Amazon Bedrock Managed Knowledge Base, you can now combine single-shot RAG, agentic retrieval, and retrieval-only requests in one assistant through AgenticRetrieveStream. In the banking example, you can answer the account-opening checklist question with maxAgentIteration=1 and response generation enabled, which produces an answer without planning calls. For the comparison across business structures, you can set maxAgentIteration=4 to allow additional searches before the response is generated. When an employee needs to read the policy text, you can set maxAgentIteration=0 with response generation disabled to return passages without calling a language model. Your application selects the mode, and employees keep using the same assistant.
To adopt the new modes in an existing application, start with a representative set of questions and expected answers from your own documents. Compare single-shot RAG with your current agentic configuration using the same knowledge base. Measure response latency and request cost, and check whether answers are correct and supported by the retrieved passages. Include questions whose answers span several documents, and questions the documents can’t answer, so a faster response doesn’t hide missing evidence or unsupported conclusions.
Use those results to choose the lowest iteration limit that meets each workflow’s quality requirements. Keep agentic retrieval where additional searches improve the answer, use single-shot RAG where one retrieval is sufficient, and disable generation when the task is source review. Existing requests with values from 2–5 remain unchanged, so you can introduce the new modes selectively rather than redesigning the entire application.
To get started, configure maxAgentIteration and generateResponse in your requests using the AgenticRetrieveStream API reference, then evaluate the settings against your application’s questions and response-time targets. To learn more about the service, visit the Amazon Bedrock Managed Knowledge Base service page.
About the authors
Siddhant Sahu
Siddhant is a Senior Product Manager at AWS, where he leads product development for Amazon Bedrock Managed Knowledge Base. He focuses on building and rolling out infrastructure software services that handle multi-modal, multi-lingual enterprise data through fully managed ingestion, parsing, and agentic search pipelines, in a cost-efficient, accurate, and secure way, using state-of-the-art capabilities such as hybrid search, multi-shot retrieval, tool use, and embedding techniques. His work enables thousands of enterprise customers and ISVs to build agents at scale.
Chinmayee Rane
Chinmayee is a Worldwide Generative AI Specialist Solutions Architect at AWS, focused on helping organizations put agentic AI into practice with Amazon Bedrock AgentCore and Amazon Quick. She works with customers and partners to connect enterprise knowledge, automate business workflows, and turn data into actionable insights. Her work spans solution architecture and hands-on technical enablement, helping teams move from experimentation to practical adoption. With a background in applied mathematics and machine learning, she bridges technical depth with a clear focus on business outcomes. Outside of work, she enjoys salsa and bachata dancing.
Josh DeMuth
Josh is a Generative AI Solutions Architect at AWS. Over 20 years in the tech industry, including several years in systems integration, he has focused on making disparate systems work together. He now helps customers build generative AI applications that work with the systems and data they already have.
Rohan Karhadkar
Rohan is a Software Development Engineer at Amazon Web Services. He builds agentic retrieval systems for Amazon Bedrock Managed Knowledge Base and Amazon Quick. His work lets AI agents plan multi-step searches, retrieve permission-aware enterprise data, and generate grounded answers with accurate citations.
Qihao Shao
Qihao is a Senior Software Engineer at Amazon Web Services, where he works on agentic retrieval systems for Amazon Bedrock Managed Knowledge Base and Amazon Quick.
正文保留英文原文,标题与摘要由机器翻译。
原文发布于 AWS Machine Learning(Single-shot and agentic retrieval with Amazon Bedrock Managed Knowledge Base),标题、摘要与正文由机器翻译,术语按行业惯例统一,未经人工逐句校订。