プログラミング

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

本文は SEO 深度のため主に中国語です。上記は要点のローカライズ。言語切替と深リンクで国際ナビできます。

## 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 citation pipeline to maintain. This tool delivers a complete, grounded response in seconds directly from the AWS gateway, making it ideal for AI agents that need up-to-date web information without custom retrieval logic. For developers building agents with GrokCode API 中转, it accelerates coding by replacing multi-step pipelines with one reliable MCP call, especially when integrating with models like Claude Code or Grok for real-time accuracy.

Web Answer on Amazon Bedrock AgentCore 是专为 AgentCore Gateway 设计的编码工具。它将自然语言提问转换为带来源引用的合成答案,只需一次工具调用即可完成。AWS 官方在 2026-11-05 正式宣布该功能,该工具会实时搜索、验证页面事实,并在必要时迭代证据,确保回答始终最新且可追溯。 [[1]](https://aws.amazon.com/blogs/machine-learning/getting-started-with-web-answer-on-amazon-bedrock-agentcore/)

适用人群:

  • 需要实时数据支持的 Agent(如金融、新闻、法律研究)
  • 追求低维护成本的编码 Agent 开发者
  • 已在 AWS 上运行 AgentCore 的团队

决策点:如果你已经在 AgentCore Gateway 上部署工具,且问题属于“当前事实类”而非历史或通用知识,就无需再写搜索-合成-引用的自定义代码;只需添加 Web Answer target 即可直接调用。相比 Web Search 工具,它帮你省去了模型调用、结果清洗和归因环节,适合作为子任务嵌入更大 Agent。

核心优势与工作机制

Web Answer 将传统 Agent 常用的“搜索-检索-合成-引证”流程全部托管。AgentCore Gateway 认证后,调用 Web Answer 进行多轮并行搜索,读取关键页面验证事实,当证据不足时自动补充。最终输出包含完整引用链接,每个 claim 直接指向 source URL。

与 Web Search 工具对比(表格横向滚动友好):

维度Web AnswerWeb Search
输出结果合成带引用的完整答案排名 URL、标题、片段和元数据
维护难度零维护(托管)需要你处理合成和归因逻辑
使用场景Agent 内部子任务(快速事实回答)需你控制处理流程的广度研究任务
响应时间几秒内完成取决于你后续处理
成本控制单一工具调用计费搜索 + 模型调用双重计费

许多团队会结合两者使用:Web Search 做宽泛调研,Web Answer 处理具体提问。

如何添加与调用 Web Answer(Python 示例)

准备工作(5 分钟完成):

  • AWS 账户 + AgentCore Gateway(us-east-1,IAM 认证)
  • Python 3.10+,安装:pip install boto3 strands-agents mcp mcp-proxy-for-aws

步骤 1:授予 Gateway 服务角色权限 在 IAM 中为 gateway-service-role 添加内联策略,允许 bedrock-agentcore:InvokeWebAnswer(资源为 arn:aws:bedrock-agentcore:us-east-1:aws:tool/web-answer.v1)。

步骤 2:创建 Web Answer target 通过 bedrock-agentcore-control Client 添加 target,配置 MCP connector。target 状态变为 READY 后即可使用。

步骤 3:从 Agent 调用 使用 MCPClient 连接 Gateway(URL 为 >.gateway.bedrock-agentcore.us-east-1.amazonaws.com/mcp),然后通过 agent("你的问题") 触发工具调用。示例代码如下:

```python 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(白名单/黑名单)、publishedAfter、country 等,可在 agent 层控制。

返回格式包含 content(Markdown 带 [1](url) 标记)和 structuredContent(结构化 citations 列表),方便后续解析。

与 GrokCode 编程中转的协同实践

在 GrokCode API 中转体系中,Web Answer 作为编码工具可直接包装进 MCP 客户端,与本地 vLLM 或官方 API 模型并行调用。开发者可为 Grok API 或 xAI 中转添加类似 gateway 层,实现“单次工具调用 + 实时搜索”的编码 Agent。结合 GrokCode /channels 页面提供的模型列表,你可以测试 Claude Code 与 Grok 的混合调用场景,快速验证合成回答的质量。

扩展阅读

  • [GrokCode 编程入门]
  • [API 中转入门]
  • [模型天梯与本地部署]
  • [官方 API 接入]

风险与边界

风险与边界 使用 Web Answer 时,请注意以下边界:

  • 仅支持 IAM 或 JWT 认证的 AgentCore Gateway
  • 每次调用会产生 Gateway 费用(具体以 AWS 定价页面为准)
  • 证据不足时工具会自动迭代,但仍可能存在边缘事实偏差
  • 推荐在测试环境中验证 domainFilter 配置,避免敏感信息泄露

非法律意见声明 本文仅供技术参考,不构成法律、财务或合规建议。所有资源管理、权限配置和计费请参考官方文档并咨询专业 AWS 顾问。AWS 保留随时调整服务的权利。

English summary

Amazon Bedrock AgentCore Web Answer is a fully managed tool that returns a single synthesized, source-cited answer to any natural-language question in one MCP tool call. Launched on November 5, 2026, it replaces the traditional multi-step pipeline of searching, retrieving, synthesizing, and attributing web content with an agentic loop that plans searches in parallel, verifies facts on key pages, and adds citations automatically. It differs from the Web Search tool by handling synthesis and attribution for you, making it ideal for sub-tasks inside larger coding agents. Setup involves adding the Web Answer target to your Gateway and calling it via standard MCP endpoints from Strands, LangChain, or similar clients. Response format includes both markdown text and structured citations for easy parsing. When paired with GrokCode API transit or local deployment setups, it accelerates real-time agent development for current events, research, or coding tasks. Always review official pricing and permissions before production use.

(正文字数约 2850,去除空白字符后中文为主)

适用于 GrokCode 倍率榜。信息仅供参考,不构成购买、投资或法律意见。