Asynchronous patterns for calling Amazon Bedrock AgentCore agents in serverless pipelines
In this post, you learn three serverless patterns (task-token callback, direct service integration, and durable functions) for invoking Amazon Bedrock AgentCore agents asynchronously from AWS Step Functions pipelines, eliminating idle compute costs while your AI agent processes requests.
Asynchronous execution patterns for Amazon Bedrock AgentCore agents in serverless pipelines help reduce idle compute costs when processing requests. A typical use case is document validation within a real estate financing back office. AgentCore enables building, connecting, and optimizing agents at scale with any framework or model.
These agents differ from traditional pipeline steps by incorporating thinking time before responding, which varies based on the prompt, model, and document but is rarely instantaneous. The common initial implementation involves an AWS Lambda function that invokes the agent and waits for the response, leading to wasted compute resources as the function remains active and billed during the wait. However, Amazon Bedrock AgentCore runtime charges memory but not CPU during idle periods.
The compute service calling the agent incurs this cost, while the agent itself does not. To optimize costs, the caller's compute should release during the wait and resume when the agent has a result. This post presents three patterns (task-token callback, direct service integration, and durable function) to achieve this, contrasting them with the blocking anti-pattern.
An example pipeline, consisting of five stages—Extract, Identify, Route, Organize and Validate, and Result—is used to compare the patterns. Each pattern's Validate branch differs, but the overall pipeline remains unchanged.
The agent inspects the invocation and responds accordingly: using AWS Step Functions task tokens to wake the execution, durable-function callback IDs to wake the durable function, or returning the verdict directly if neither is present. This allows changing the orchestration pattern without altering or redeploying the agent. The agent returns control without blocking the caller by calling a Lambda that posts the result and task token back to Step Functions.
This Lambda code handles the conclusion of validation and determines whether to resume Step Functions or a durable function execution based on the received signals.
Written by urgent.news from AWS Machine Learning's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.
This story
This is one outlet's version. Read the fullest account.