GEO

如何使用AWS AgentCore构建个性化AI新闻摘要助手?2026最新教程

2026/5/7
如何使用AWS AgentCore构建个性化AI新闻摘要助手?2026最新教程

AIAI Summary (BLUF)

This article provides a step-by-step guide to building a personalized AI news digest agent ('The Pulse') using AWS AgentCore's managed harness. It covers architecture, prerequisites, deployment, scheduling, and cost estimation.

原文翻译:
本文提供了使用AWS AgentCore托管Harness构建个性化AI新闻摘要代理(“The Pulse”)的分步指南,涵盖架构、前提条件、部署、调度和成本估算。

核心洞察

The "AgentCore Managed Harness" represents a paradigm shift in how developers build persistent, stateful AI agents on AWS. By abstracting away browser management, persistent storage, and long-running execution, it enables a single-agent architecture that previously required orchestrating five separate services. This approach signals that in 2025, the barrier to creating a personal "Jarvis"-like assistant is no longer technical complexity, but rather creativity in prompt engineering and tool configuration.

"AgentCore托管式Harness"代表了开发者在AWS上构建持久化、有状态AI Agent的一种范式转变。通过抽象化浏览器管理、持久化存储和长时间运行的执行过程,它实现了以前需要协调五个独立服务才能完成的单Agent架构。这种方法表明,在2025年,创建个人"Jarvis"式助手的障碍不再是技术复杂性,而是提示词工程和工具配置方面的创造力。


What We're Building / 我们正在构建什么

I want an AI agent that works for me. I want it to search up the latest news, and I want it to deliver it to me in a daily message. I want to chat with it, and get advice. I want to expand its capabilities in the future. And most importantly I want to control it. Basically, I want Jarvis.

我想要一个为我工作的AI Agent。我希望它能搜索最新新闻,并以每日消息的形式推送给我。我希望能与它聊天并获得建议。我希望在未来扩展它的能力。最重要的是,我希望控制它。基本上,我想要一个"贾维斯"。

Yes Jarvis, the fictional AI character in the Marvel Cinematic Universe (MCU), serving as Tony Stark's butler. I've never had my own agentic butler, and now that I think about it who wouldn't? A few years ago I would have told you this would have never happened. But today with the rise of agents the future is here.

没错,就是漫威电影宇宙中为托尼·斯塔克服务的虚构AI管家贾维斯。我从未拥有过自己的Agent管家,仔细想想,谁不想要一个呢?几年前我还会告诉你这是不可能的事。但今天,随着Agent的兴起,未来已经到来。

Well sort of... we are getting closer than ever though!

好吧,某种程度上...我们比以往任何时候都更接近了!

To take on this task one of the most obvious routes was to use something like OpenClaw. Except, OpenClaw is too new, and a little too much for what I needed, so like any good engineer I decided to roll my own. OpenClaw is an open-source, autonomous AI agent that runs locally on a your machine or VPS to automate tasks.

为了完成这个任务,最直接的途径之一是使用类似OpenClaw的工具。不过,OpenClaw太新了,而且对于我的需求来说有些过于复杂,所以像任何优秀的工程师一样,我决定自己动手构建。OpenClaw是一个开源的自主AI Agent,它在你的本地机器或VPS上运行以自动执行任务。

Recently Amazon Bedrock AgentCore released its managed harness in preview. You define the agent in a config file and a system prompt, and then deploy it. That was it! From my research it looked very straightforward to get up and running, and it could save me a lot of time in the long run. So I decided to take the journey to create my very own Jarvis.

最近,Amazon Bedrock AgentCore 发布了其托管式Harness的预览版。你只需在配置文件和系统提示词中定义Agent,然后部署即可。就这么简单!根据我的研究,它上手和运行都非常直接,从长远来看可以节省大量时间。所以我决定踏上这段旅程,创建属于我自己的"贾维斯"。

After several hours of tinkering and research I created "The Pulse." It opens Hacker News in a real browser, grabs Reddit posts via RSS, saves everything to persistent storage, and every 6 hours writes a trending stories digest. It messages me every day, or I can message it anytime and ask what's happening in AI. It reads from the data it's been collecting all day.

经过几个小时的调试和研究,我创建了"The Pulse"。它在一个真实的浏览器中打开Hacker News,通过RSS抓取Reddit帖子,将所有内容保存到持久化存储中,每6小时写一份热门故事摘要。它每天给我发消息,或者我可以随时联系它,询问AI领域的最新动态。它会读取自己一整天收集的数据。

The architecture diagram below illustrates the flow: EventBridge fires every hour and triggers a Lambda. The Lambda makes one API call to the harness. Inside the harness, the agent runs in its own microVM — a lightweight virtual machine that spins up just for your session with its own CPU, memory, and filesystem. The agent opens a browser, scrapes HN, fetches Reddit RSS, and saves a snapshot. Every 6th run it reads all the snapshots, finds trends, and writes a digest. Because the session ID stays the same across runs, all that data accumulates on /mnt/data. You can also just talk to it anytime through the CLI and ask what's trending.

下图的架构说明了整个流程:EventBridge每小时触发一次Lambda。该Lambda向Harness发起一次API调用。在Harness内部,Agent在其自己的microVM中运行——这是一个轻量级的虚拟机,专为你的会话启动,并配有独立的CPU、内存和文件系统。Agent会打开浏览器,抓取HN,获取Reddit RSS,并保存快照。每运行6次,它会读取所有快照,发现趋势,并撰写一份摘要。由于会话ID在多次运行中保持不变,所有数据都会累积在/mnt/data目录下。你也可以随时通过CLI与它交流,询问当前的热门话题。


Why Not Just Use Lambda? / 为什么不直接使用Lambda

Before we get into the details, one question you may be thinking is couldn't we do all this with just a Lambda, some Strands Agents code, an LLM, and a dream? For a simple one-shot task, you are probably right. But this agent needs a few things Lambda can't give you, which makes this approach well worth it.

在深入细节之前,你可能在想:难道不能只用Lambda、一些Strands Agents代码、一个LLM和梦想来完成这一切吗?对于简单的单次任务,你可能是对的。但这个Agent需要Lambda无法提供的几个关键能力,这使得当前的方法非常值得。

Let's break down the key differentiators:

让我们来分析一下关键的差异化因素:

Requirement AgentCore Harness Lambda-Only Approach Multi-Service Alternative
Browser Support Managed headless Chrome via agentcore_browser tool Not supported; need Fargate + Playwright Fargate + Playwright + custom container management
Persistent Storage Built-in sessionStoragePath at /mnt/data, persists across invocations /tmp is ephemeral, wiped after each invocation S3 + custom read/write logic for every file operation
Execution Time Limit Default 1 hour (configurable); session lifespan up to 8 hours Hard limit of 15 minutes Step Functions for orchestration
Memory / Context Built-in AgentCore Memory for facts, preferences, conversation summaries None; requires DynamoDB + custom integration DynamoDB + custom proximity-based retrieval
Infrastructure Complexity Single managed harness Simple but insufficient Fargate + S3 + DynamoDB + Step Functions (5 services)

First, the agent opens a real browser to scrape Hacker News. Lambda can't spin up a managed browser session. You'd need Fargate plus Playwright, and now you're managing containers.

首先,Agent打开一个真实的浏览器来抓取Hacker News。Lambda无法启动托管的浏览器会话。你需要Fargate加上Playwright,但这又涉及管理容器。

Second, it saves hourly snapshots to /mnt/data/runs/ and reads them back 6 hours later. Lambda's /tmp gets wiped after every invocation. You'd need S3 plus custom read/write logic for every file operation. That's a lot of work for what should be "save a file."

其次,它每小时将快照保存到/mnt/data/runs/,并在6小时后读取回来。Lambda/tmp目录在每次调用后都会被清空。你需要S3加上自定义的读写逻辑来处理每次文件操作。对于一个本应是"保存文件"的操作来说,工作量太大了。

Third, the 6-hour summary run reads all the accumulated data, compares scores across snapshots, identifies trends, and writes a digest. That can take a while. Lambda maxes out at 15 minutes. The harness defaults to a 1-hour timeout per invocation (I set mine to 30 minutes since that's plenty), and the microVM itself can stay alive for up to 8 hours across multiple invocations.

第三,每6小时的摘要运行会读取所有累积的数据,比较不同快照的评分,识别趋势,并撰写摘要。这可能需要一段时间。Lambda的最大执行时间为15分钟。而Harness默认每次调用有1小时的超时时间(我将其设置为30分钟,因为已经足够了),其microVM本身在多次调用之间可以保持活跃长达8小时。

And then there's memory. AgentCore Memory is a built-in service that stores facts, preferences, and conversation summaries across sessions. So "What did I ask about yesterday?" works because the memory carries context forward. In Lambda, you'd need DynamoDB plus a custom integration.

接着是记忆能力。AgentCore Memory是一个内置服务,可以跨会话存储事实、偏好和对话摘要。因此,"我昨天问了什么?"之所以能工作,是因为记忆能向前传递上下文。在Lambda中,你需要DynamoDB加上自定义集成。

Could you build all of this with Lambda plus S3 plus Fargate plus DynamoDB plus Step Functions? Sure. That's five services instead of one. That's four too many for this tutorial.

你能用Lambda加上S3、Fargate、DynamoDB和Step Functions来构建所有这些吗?当然可以。但那是五个服务,而不是一个。对于本教程来说,这多出了四个服务。


Prerequisites / 前提条件

  • Node.js 20+
  • AWS credentials configured in a preview region (us-west-2, us-east-1, eu-central-1, or ap-southeast-2)
  • CDK bootstrapped in your account (cdk bootstrap)
  • AgentCore CLI installed globally
  • Bedrock model access for Claude Sonnet 4.6 in your region
  • Node.js 20+
  • 在预览区域配置了AWS凭证us-west-2us-east-1eu-central-1ap-southeast-2
  • 在你的账户中引导了CDKcdk bootstrap
  • 全局安装了AgentCore CLI
  • 在你的区域中拥有Claude Sonnet 4.6的Bedrock模型访问权限

Create the Harness Project / 创建Harness项目

This is where the fun begins. We'll create our very first managed harness.

有趣的部分从这里开始。我们将创建第一个托管式Harness。

agentcore create \
  --name thepulse \
  --model-provider bedrock \
  --session-storage-mount-path /mnt/data

cd thepulse

That one command scaffolds the whole project. Harness config, memory, session storage, CDK app, IAM role. The --session-storage-mount-path flag wires up persistent storage so the platform creates a /mnt/data mount point for you. You don't have to worry about a Dockerfile, or container to manage.

这一个命令就能搭建起整个项目:Harness配置、记忆、会话存储、CDK应用、IAM角色。--session-storage-mount-path标志连接了持久化存储,平台会为你创建一个/mnt/data挂载点。你无需担心Dockerfile或管理容器的问题。

Now add the browser tool. AgentCore Browser is a managed headless Chrome instance that the harness can spin up on demand. Your agent can navigate pages, click elements, extract content, basically anything you'd do with Playwright but without managing the browser infrastructure yourself.

现在添加浏览器工具。AgentCore Browser是一个托管式的无头Chrome实例,Harness可以按需启动它。你的Agent可以导航页面、点击元素、提取内容,基本上所有你用Playwright能做的事情都可以做到,而且无需自己管理浏览器基础设施。

agentcore add tool --harness thepulse --type agentcore_browser --name browser

Here's what you end up with:

最终你会得到如下项目结构:

thepulse/
├── agentcore/
│   ├── agentcore.json          # Project-level resource config
│   ├── aws-targets.json        # Deployment targets (account, region)
│   ├── .env.local              # Local dev config (gitignored)
│   └── cdk/                    # CDK TypeScript app
├── app/
│   └── thepulse/
│       ├── harness.json        # Agent config
│       └── system-prompt.md    # Agent instructions

Configure the Agent / 配置Agent

Our AgentCore CLI already set up the model, memory, and session storage. You just need to tweak the execution limits and write the system prompt.

AgentCore CLI已经设置好了模型、记忆和会话存储。你只需要调整执行限制并编写系统提示词即可。

Edit app/thepulse/harness.json:

编辑 app/thepulse/harness.json 文件:

{
  "name": "thepulse",
  "model": {
    "provider": "bedrock",
    "modelId": "global.anthropic.claude-sonnet-4-6"
  },
  "tools": [
    {
      "type": "agentcore_browser",
      "name": "browser"
    }
  ],
  "skills": [],
  "memory": { "name": "thepulseMemory" },
  "sessionStoragePath": "/mnt/data",
  "maxIterations": 75,
  "timeoutSeconds": 1800
}

Key configuration parameters explained:

关键配置参数说明:

Parameter Value Why This Matters
modelId global.anthropic.claude-sonnet-4-6 Uses the global. prefix for region-agnostic, serverless inference
tools agentcore_browser Enables the agent to launch and control a real headless Chrome browser
sessionStoragePath /mnt/data Persistent file storage that survives across multiple agent invocations
maxIterations 75 Allows complex multi-step workflows (browsing, reading, summarizing)
timeoutSeconds 1800 30-minute window per invocation, sufficient for 6-hour batch digest processing

常见问题(FAQ)

使用AWS AgentCore托管Harness构建AI新闻摘要代理需要哪些前提条件?

需要有效的AWS账户、Bedrock服务权限、AgentCore托管Harness预览版访问权限,并熟悉Lambda、EventBridge及AWS CLI等基础工具。

AgentCore托管Harness相比直接使用Lambda有什么优势?

它抽象了浏览器管理、持久化存储和长期运行,支持有状态单代理架构,无需协调多个服务,显著降低开发复杂度。

如何调度“The Pulse”代理按计划运行并生成每日摘要?

使用EventBridge每小时触发Lambda调用Harness API,代理在微VM中运行,每6小时汇总快照发现趋势并写入摘要,数据持久化在/mnt/data。

← 返回文章列表
分享到:微博

版权与免责声明:本文仅用于信息分享与交流,不构成任何形式的法律、投资、医疗或其他专业建议,也不构成对任何结果的承诺或保证。

文中提及的商标、品牌、Logo、产品名称及相关图片/素材,其权利归各自合法权利人所有。本站内容可能基于公开资料整理,亦可能使用 AI 辅助生成或润色;我们尽力确保准确与合规,但不保证完整性、时效性与适用性,请读者自行甄别并以官方信息为准。

若本文内容或素材涉嫌侵权、隐私不当或存在错误,请相关权利人/当事人联系本站,我们将及时核实并采取删除、修正或下架等处理措施。 也请勿在评论或联系信息中提交身份证号、手机号、住址等个人敏感信息。