AWS has introduced three asynchronous invocation patterns for calling Amazon Bedrock AgentCore agents in serverless pipelines to reduce idle compute costs. These patterns help avoid the cost of keeping compute resources active while an AI agent processes requests, which is common in workflows like document validation for real-estate financing. The asynchronous approach allows the caller to release compute resources during the wait, thereby minimizing unnecessary charges. The solution is designed to optimize cost efficiency by aligning the caller's cost with the agent's runtime rather than the entire processing time.
The three patterns—task-token callback, direct service integration, and durable function—each offer a different way to invoke the agent without blocking the caller. The task-token callback pattern uses a Lambda function to resume execution once the agent has completed its processing, while the durable function pattern eliminates the need for a Lambda function entirely by integrating Step Functions directly with AgentCore. These patterns are tested using a simple pipeline that validates documents, with only the Validate branch changing to demonstrate each pattern. The agent can be configured to respond using a task token, a durable-function callback ID, or a synchronous call, depending on the orchestration pattern used.
The article provides a detailed example of a pipeline used to compare the patterns, including an extraction, classification, routing, and validation stage. The pipeline is designed to be a placeholder for any workflow that involves an agent or a slow service. The core of the solution lies in the agent’s ability to return control to the caller without blocking, which is achieved through a return-of-control action in the agent’s action group. This mechanism allows the pipeline to resume only when the agent has a result, optimizing resource usage and cost.
Source: awsml