Building ambient agents with Amazon Bedrock AgentCore: From event-driven signals to human-in-the-loop workflows
https://aws.amazon.com/blogs/machine-learning/building-ambient-agents-with-amazon-bedrock-agentcore-from-event-driven-signals-to-human-in-the-loop-workflows/📌 AWS AgentCore打造「環境式」代理:事件觸發,人類只在需要時介入
TL;DR:AWS展示如何用Bedrock AgentCore打造ambient agent,靠事件觸發取代對話框,並用單一ask_human工具實現human-in-the-loop。
檔案一上傳到S3,幾秒內工作就自動出現在Jobs頁面並開始執行,不需要任何人打開聊天視窗、輸入提示詞。這就是文章所稱的「ambient agent」。
🤔 背景:聊天式agent撐不起事件驅動的場景
多數AI agent體驗遵循請求—回應模式:使用者打開聊天介面、輸入提示、等待回覆。這適合一次性提問,但限制agent一次只能處理一個對話,而且需要人類先描述發生了什麼事,agent才能行動。對於檔案上傳、資料庫變更、排程任務、系統告警這類「事件發生在基礎設施各處」的場景,這套聊天模式就不夠用了。AWS指出,LangChain等業者已提出「ambient agent」這個不同典範:agent監聽事件串流並據此行動,可能同時處理多個事件,而非只由人類訊息觸發。但ambient agent並非完全自主,正式環境的設計會謹慎考慮agent該在什麼時候暫停並與人互動。
🧩 架構:事件→agent→人在迴圈中
文章定義的ambient signal,是一個「事件來源對應agent」的設定。事件發生時,平臺自動幫該agent建立一個job。整個流程端到端如下:Amazon S3發出s3:ObjectCreated通知;Signal Processor Lambda接收通知,查詢ambient-signals資料表的GSI,找出符合的signal,為每個符合項建立job紀錄;API層(或排程器)把job放進Amazon SQS佇列;Job Execution Lambda透過SQS event source把佇列清空,呼叫Amazon Bedrock AgentCore Runtime上的agent,並把結果(以及任何需要人類輸入的請求)寫回Amazon DynamoDB;透過Amazon CloudFront供應的React前端,輪詢一個小型Amazon API Gateway與Lambda層取得更新,讓使用者回應待處理的互動。
Amazon Bedrock AgentCore Runtime提供容器化的agent執行環境,支援長時間執行的workload、內建session隔離,並與Bedrock基礎模型整合。參考實作把每個agent turn的上限設在Lambda的15分鐘逾時,文章表示這在實務上已綽綽有餘。整體加上處理事件的AWS Lambda與管理狀態的Amazon DynamoDB,組成一套全serverless的ambient-agent平臺。
agent與人類的互動,全部透過單一工具ask_human完成,並回傳一個標準化的response envelope:狀態為completed、interrupted或error三者之一,對應欄位分別是result、question、error,另外session_id與job_id會貫穿每個回應以便串接後續輪次。當agent回傳interrupted,平臺會把job狀態改為interrupted並將requiresAction旗標設為true,React前端會在Jobs頁面的Interrupted分頁上用警示圖示標示出來,不需要另外的審核佇列。同一個Jobs畫面同時顯示待回答的問題、等待核準的提案行動、最終結果與失敗的job,讓使用者只需要看一個地方,而不是在多個聊天視窗或郵件串之間來回監看。
這套ask_human機制同時支援幾種提示樣式:Notify(agent單純回報結果)、Question(agent詢問澄清)、Review(agent提出行動並等待APPROVE/REJECT/MODIFY)、Error(失敗被記錄在job紀錄上,由使用者決定是否重試)。文章強調,這些只是agent撰寫問題時的慣例,平臺層面其實只有一條程式碼路徑與一種envelope格式。
💡 為何不用純自動化pipeline就好
文章點出兩種既有方案的侷限:全自動的pipeline(如AWS Step Functions)能編排workflow,但無法對模糊情境做推理或提出澄清問題;聊天式agent能推理,但需要有人先開啟對話。Ambient agent被定位為介於兩者之間的橋樑。AWS也指出,許多組織在AWS上已經具備事件驅動基礎建設(S3事件通知、EventBridge規則、Lambda觸發、DynamoDB streams),缺的只是把這些事件來源接上能推理、能行動、必要時能拉人進來的agent。
⚠️ 限制
素材提到的signal事件來源中,參考範例只實作了S3與排程兩種,其餘(如資料庫變更、系統告警)屬於擴充點,需要自行撰寫新的handler Lambda與對應的Signals頁面欄位。
🎯 實務啟示
如果你的團隊已經有文件落地S3、告警堆積等「沒人即時處理」的場景,這套ambient agent模式提供了一個現成的架構骨架:事件驅動觸發、單一human-in-the-loop工具、統一的Jobs視圖。比起從頭設計agent該何時暫停等人,直接參考這個ask_human envelope的設計(completed/interrupted/error三態)可以省下不少架構決策時間。
🔗 來源
- 標題:Building ambient agents with Amazon Bedrock AgentCore: From event-driven signals to human-in-the-loop workflows
- 作者/機構:Juan Albarran,AWS Machine Learning Blog
- 連結:https://aws.amazon.com/blogs/machine-learning/building-ambient-agents-with-amazon-bedrock-agentcore-from-event-driven-signals-to-human-in-the-loop-workflows/
#AWS #BedrockAgentCore #AmbientAgents #HumanInTheLoop #EventDriven #Serverless #AIAgent #AWSLambda #AgenticAI #CloudArchitecture
原始資料 AWS ML · 收集於 2026-10-01
摘要原文
Teams that process documents at scale know the routine: files land in storage, someone notices, opens each one, decides what it needs, and routes it for review. Monitoring alerts queue up the same way, waiting for a person to act on them. The hours lost to manual triage are the operational problem ambient agents solve. Imagine a document lands in your Amazon Simple Storage Service (Amazon S3) bucket and within seconds a job appears on your Jobs page, ready to run (or already running if you configured it that way). The agent analyzes the file, surfaces the findings, and asks you for approval before taking the next step. The event itself is the prompt. That is an ambient agent: it responds to event streams, pauses for human input through a single ask_human tool when it needs to, and resumes from where it left off once the human answers. Figure 1: Overview of an ambient agent responding to an event on AgentCore Runtime and pausing for human input Most AI agent experiences today follow a different pattern: a user opens a chat interface, types a prompt, and waits for a response. That works for one-time questions, but it limits the agent to one conversation at a time and requires a human to describe what happened before anything can act on it. For scenarios where agents should react to events happening across your infrastructure (file uploads, database changes, scheduled tasks, system alerts), that chat-only model breaks down. Ambient agents describe a different paradigm, one that LangChain among others has articulated. Instead of waiting for users to initiate conversations, ambient agents listen to an event stream and act on it, potentially handling many events in parallel. They aren’t solely triggered by human messages, and multiple agents can run simultaneously. Crucially, they aren’t fully autonomous: a production design pays careful attention to when the agent pauses to interact with humans. When a signal fires, the agent executes its workflow and only interrupts a human when clarification, approval, or review is needed. This human-in-the-loop component lowers the stakes for deploying agents to production, builds user trust, and lets agents learn and improve over time through feedback. Organizations running on AWS already have the event-driven infrastructure in place: Amazon S3 event notifications, Amazon EventBridge rules, AWS Lambda triggers, and Amazon DynamoDB streams. The missing piece is connecting those event sources to intelligent agents that can reason about what happened, act, and loop in humans when the situation calls for it. Fully automated pipelines like AWS Step Functions can orchestrate workflows but can’t reason through ambiguity or ask clarifying questions. Chat-based agents can reason but require someone to start the conversation. Ambient agents bridge this gap. Amazon Bedrock AgentCore is a platform to build, connect, and optimize agents at scale, with any framework or model. AgentCore Runtime provides the execution environment that makes this pattern work: container-based agent hosting with support for long-running workloads, built-in session isolation, and integration with Amazon Bedrock foundation models. AgentCore Runtime supports sessions long enough to cover the signal → agent → human-in-the-loop (HITL) flow shown here. The reference implementation caps each agent turn at the Lambda 15-minute timeout, which is more than enough headroom in practice. Combined with AWS Lambda for event processing and Amazon DynamoDB for state management, the result is a fully serverless ambient-agent platform. In this post we walk through the pattern end-to-end on Amazon Bedrock AgentCore. You will come away understanding: Before deploying the reference implementation, make sure you have the following in place: Before we get into the architecture, it helps to look at what makes an ambient agent different from a typical chatbot and at the building blocks the rest of the post relies on: the event-driven trigger model, the ambient signal abstraction, and the single human-in-the-loop tool that ties them together. User-initiated agents follow a request-response pattern: Ambient agents follow an event-driven pattern: The key difference is the trigger mechanism. Ambient agents are activated by system events rather than explicit user requests, which makes them a natural fit for document-processing pipelines, monitoring and alerting, scheduled analysis, and multi-step workflows that need approval gates along the way. An ambient signal is a configuration that maps an event source to an agent. When the event occurs, the platform automatically creates a job for the agent. What happens next depends on one setting on the signal: The pattern covers several signal event sources. The reference sample ships the first two. The rest are extension points you add by writing a new handler Lambda function and a corresponding form field on the Signals page: Ambient agents need structured ways to interact with humans. In this sample the agent surfaces those interactions through a single tool ( ask_human ) and returns a canonical response envelope. In that envelope, status is one of completed , interrupted , or error , and the matching field is result , question , or error . The platform additionally threads session_id and job_id through every response so continuation turns can be correlated. Those are correlation metadata, not part of the core contract your agent must implement. When the agent returns interrupted , the platform moves the job into interrupted status and sets its requiresAction flag to true . The reference React frontend surfaces these on the Interrupted tab of the Jobs page with a warning indicator on each row, so there is no separate review queue to poll. The same Jobs view shows pending questions, proposed actions awaiting approval, final results, and failed jobs, giving a user one place to see everything their agents are doing instead of monitoring multiple chat windows or email threads. The same mechanism supports several prompting patterns that a reader may recognize from the wider agents literature: a Notify turn where the agent simply reports a result, a Question turn where it asks for clarification, a Review turn where it proposes an action and waits for APPROVE / REJECT / MODIFY , and an Error turn where the failure is captured on the job record and the user decides whether to retry. These are conventions for how the agent writes its question, not separate runtime modes. At the platform level there is exactly one code path and exactly one envelope. Figure 2: The Notify, Question, and Review human-in-the-loop patterns, all surfaced through the ask_human tool The platform is a small set of serverless components stitched together by an event pipeline. This section walks through the end-to-end flow first, then describes each component in turn. Events flow through the platform end-to-end as follows. Amazon S3 emits an s3:ObjectCreated notification, which a Signal Processor Lambda function receives. The Signal Processor queries a global secondary index (GSI) on the ambient-signals table to find any matching signal for the event bucket, then creates a job record for each match. The API tier (or the scheduler) enqueues the job onto an Amazon SQS queue. The same Job Execution Lambda function that serves the API path also drains the queue through an attached SQS event source, invokes the agent on Amazon Bedrock AgentCore Runtime, and writes results (and any human-input requests) back to Amazon DynamoDB. A React frontend served from Amazon S3 through Amazon CloudFront polls a small Amazon API Gateway and Lambda tier for updates and lets the user respond to pending interactions. Figure 3: Event flow from Amazon S3 through Amazon SQS and AWS Lambda to AgentCore Runtime, with state in Amazon DynamoDB and a React frontend With the architecture in mind, the next step is wiring up the event source that turns an Amazon S3 upload into an agent job.
由 claude-code/sonnet 自動生成