Serverless & Agentic AI: Better Together • Prashanth HN • GOTO 2025
Prashanth HN explores the powerful synergy between event-driven Agentic AI and Serverless architecture. Learn how AWS services like Lambda, Step Functions, and Bedrock provide the essential building blocks for creating sophisticated, scalable, and cost-effective AI agents, with practical examples of Agentic RAG, swarms, and orchestration patterns.
The world of AI, at its core, is fundamentally event-driven. Every user query to a chatbot is an event, which can trigger multiple sub-events and complex processing. This event-driven nature makes Serverless architecture a natural and powerful foundation for building the next generation of Agentic AI applications.
Understanding the Modern AI Agent
An agent is a system that uses a Large Language Model (LLM) for its reasoning or “thinking” capabilities. It is connected to a set of tools which, in turn, have access to underlying data. This setup is not a static workflow; the LLM dynamically decides which tool to use for a given query to complete its execution.
Key characteristics of an agentic system include:
- The Agentic Loop: An agent produces an answer, which is then passed through an evaluation step. If the answer is deemed insufficient, it’s looped back with feedback to the agent for refinement until a satisfactory result is achieved.
- Multi-Agent Systems: Drawing parallels with microservices architecture, you can have an orchestrator agent managing multiple sub-agents. Each sub-agent can be specialized, using different LLMs, tools, and data sets. This approach allows for:
- Cost and Performance Optimization: Use large, capable models for complex tasks and smaller, faster models for simpler ones.
- Scoped Permissions: Limit the tools and data available to each agent, enhancing security and control (e.g., a Salesforce agent doesn’t need access to engineering data).
The Serverless Toolkit for Agentic AI
AWS provides a comprehensive set of serverless components that map directly to the needs of an agentic system.
Event Management
Since agents are event-driven, managing the flow of events is crucial.
- API Gateway: Acts as the “front door” for incoming requests, such as user queries from a front-end application.
- Amazon EventBridge: Enables complex, event-driven communication between agents, allowing any agent to publish or subscribe to events.
- SQS and SNS: Used for decoupling components. SQS queues can buffer requests between services, while SNS can fan out events to multiple subscribers.
LLM Inference
- AWS Bedrock: A fully serverless offering to access a variety of foundation models. You pay only for the tokens you use. It now supports open-weight models, increasing its flexibility.
- AWS SageMaker: For hosting custom models, including those from sources like Hugging Face.
Agent and Tool Hosting
- AWS Lambda: The ideal choice for hosting agents and tools. Lambda functions can easily access LLMs and other resources to perform their tasks.
- ECS on Fargate: A serverless container option suitable for longer-running agentic tasks.
- LangChain SDK: An essential toolkit with pre-built patterns that can significantly accelerate agent development.
Data, Vector Stores, and Memory
- Amazon S3: A foundational data store that now supports native vector search, a huge advantage for RAG systems.
- Vector Stores: Amazon Aurora PostgreSQL, OpenSearch, and the new serverless option for DocumentDB provide robust capabilities for storing and querying vectorized data.
- DynamoDB: While not a vector database, it serves as an excellent, high-performance backend for storing conversational memory and tracking chat history.
Architectural Patterns in Action
1. Agentic RAG (Retrieval-Augmented Generation)
A common pattern can be implemented in a fully serverless manner:
- A request comes through API Gateway to an agent hosted in a Lambda function.
- The agent uses Bedrock for LLM reasoning.
- It accesses tools via an MCP (Meta-Controller Protocol) server, which can also be run on Lambda.
- The tools interact with various data stores (e.g., DocumentDB, Aurora, or third-party APIs).
- Another Lambda function can be used to evaluate the generated answer and trigger the agentic loop for refinement.
2. Agent Swarms
For more complex, collaborative tasks, you can create a “swarm” of agents:
- EventBridge acts as the central bus.
- Multiple agents, running on Lambda or ECS, are hooked up to EventBridge.
- Agents can publish events and subscribe to events from other agents, allowing them to work together to solve a problem. Each agent in the swarm can be its own complex subsystem.
3. Orchestration with AWS Step Functions
While agents are inherently non-deterministic, their workflows often need to be guided. AWS Step Functions are perfect for blending this non-determinism with deterministic control.
- Serial Workflow: You can enforce a sequence of operations, such as
Research -> Write -> Review. The agent has autonomy within each step (e.g., how it does the research), but it cannot proceed to the next step until the previous one is complete. This guides the AI without stifling its capabilities. - Parallel Workflow: For requests that can be broken down, Step Functions can execute tasks in parallel. For example, a user asking for a travel itinerary to Seattle can trigger a parallel execution of three tasks: one agent finds flights, another finds hotels, and a third finds local attractions. Each of these parallel branches can be a complete subsystem with its own agents, LLMs, and data integrations. This provides a structured, deterministic workflow while still leveraging the non-deterministic power of AI in each block.