编码API

Amazon Bedrock AgentCore 集成 Web Answer

Web Answer on Amazon Bedrock AgentCore returns a synthesized, source-cited answer to a natural-language question in a single tool call, with no search, retrieve, synthesize, and ci

All guides · Full article is primarily Simplified Chinese; use the English summary below for quick takeaways (GEO-friendly).

Amazon Bedrock AgentCore 集成 Web Answer

Amazon Bedrock AgentCore 集成 Web Answer 是一项托管服务,可让代理通过单个工具调用获取自然语言查询的合成、来源引用的回答,无需自行构建搜索、检索、合成和引用管道。Cursor 开发者可将其接入 AI 编程流中,实现代码补全、文档生成或多源事实核查等任务。

谁适用:需要实时网络知识的 Cursor 项目、Windsurf 工作流或 Claude Code 会话开发者。如何决策:若查询为子任务且需快速可靠答案,直接用 Web Answer 而非 Web Search;若需原始结果或自定义合成,则保留 Web Search。

原文日期:2026-11-05(AWS 机器学习博客)。信源 rss-aws-ml(T1)提供最新官方信息,可通过本站 /channels 或 /official-api 页回溯订阅详情。

Web Answer 与 Web Search 对比

使用 Web Answer 时,代理的模型会自行规划搜索、并行执行并验证事实,最终输出已引用的完整回答。Web Search 则返回排名 URL、标题和片段,由代理方自行合成。

维度 Web Answer Web Search
输出内容 合成、来源引用的自然语言回答 原始 URL、标题、片段和元数据
模型角色 代理端自行执行检索与合成 代理方控制合成过程
使用场景 子任务中的快速事实核查 需要全面控制的广义研究任务
维护复杂度 低(AWS 托管) 中(需自建管道)

Cursor 开发者在开发流中,可根据任务复杂度选择组合使用。 [[1]](https://aws.amazon.com/blogs/machine-learning/getting-started-with-web-answer-on-amazon-bedrock-agentcore/)

集成与调用流程

AgentCore Gateway 是核心组件。代理通过 MCP 协议发现并调用 Web Answer 工具,Gateway 负责认证、权限和转发。以下是 Python 示例(基于 boto3 和 strands 代理):


from strands import Agent

from strands.models.bedrock import BedrockModel

from strands.tools.mcp import MCPClient

from mcp_proxy_for_aws.client import aws_iam_streamablehttp_client



gateway_url = ">.gateway.bedrock-agentcore.us-east-1.amazonaws.com/mcp"

mcp_client = MCPClient(lambda: aws_iam_streamablehttp_client(

 endpoint=gateway_url,

 aws_region="us-east-1",

 aws_service="bedrock-agentcore"

))

model = BedrockModel(model_id="us.anthropic.claude-sonnet-5", max_tokens=1024)



with mcp_client:

 tools = mcp_client.list_tools_sync

 agent = Agent(model=model, tools=tools)

 result = agent("What are the Basel III minimum requirements for Tier 1 capital?")

 print(result.message)

调用时可传递可选参数:domainFilter(域名限制)、publishedDateRange(日期范围)和 country(本地化结果)。响应格式包含 markdown 文本和结构化引用列表,每条 claim 均映射到 source URL。

集成到 Cursor 编码 API

在 Cursor 中,AgentCore Gateway 可作为 MCP 工具包装器接入。开发者通过 /channels?platform=cursor 页配置工具列表,即可将 Web Answer 添加到 Cursor 对话上下文或 API 代理中。代理在补全请求中触发工具调用,获取实时答案并嵌入代码中。

成本与计费

项目 详情 参考页面
Gateway 服务角色 IAM 策略:bedrock-agentcore:InvokeWebAnswer /official-api
资源清理 删除 Gateway Target 后停止计费 /api-transit/detector
计费依据 每调用一次工具的分钟级定价 /official-prices
支持的模型 任何 Bedrock 模型(Claude Code 等) /compare

以官方/挂牌页当日数据为准。实际费用取决于调用量和模型选择。

延伸阅读

风险与边界

风险与边界:

  • 若 Web Answer 无法覆盖特定来源,答案质量可能下降(AWS 负责托管部分,但代理方仍需审查引用)。
  • 网络搜索依赖实时数据,可能出现时效性问题。
  • 代理必须在可信环境运行,避免敏感查询泄露。
  • 按 AWS 官方策略使用,未经授权的自动化调用可能受限。

非法律意见声明:本文仅供技术参考,不构成法律意见或投资建议。实际应用请以官方文档和最新定价为准。