AI Agents on AWS Beginners guide to building AI agents on AWS (Bunny Kaushik, Mona M)(Z-Library)
ai
No Description
8
Views
0
Downloads
0.00
Total Donations
Registered users can read the full content for free
Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.
Page
1
(This page has no text content)
Page
2
AI Agents on AWS Beginner's guide to building AI agents on AWS Bunny Kaushik Mona M
Page
3
AI Agents on AWS Copyright © 2026 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing, or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. This book was written by Mona M and Bunny Kaushik. Generative AI tools were used only to assist with ideation, phrasing, and diagram drafts, and all technical content and code were created, verified, and tested by the author and Packt's editorial team. Packt does not accept AI-generated content that replaces expert authorship. Portfolio Director: Gebin George Relationship Lead: Sonia Chauhan Project Manager: Prajakta Naik Content Engineer: Afzal Shaikh Technical Editor: Sumant Jadhav Indexer: Manju Arasan Production Designer: Deepak Chavan Growth Lead: Nimisha Dua First published: May 2026 Production reference: 1280426 Published by Packt Publishing Ltd. Grosvenor House 11 St Paul's Square Birmingham B3 1RB, UK ISBN 978-1-80638-721-2 www.packtpub.com
Page
4
Contributors About the authors Bunny Kaushik is a Solutions Architect at AWS and an AI/ML specialist who works with the world's leading financial institutions to build scalable AI systems that deliver measurable business impact. He focuses on AI strategy, governance, and enterprise adoption, helping organizations transition from isolated prototypes to production-ready systems. He is also a published author, speaker, and active mentor to startups and professionals. He specializes in practical AI implementation, helping the next generation of builders navigate the transition from theory to production. Mona is a Senior AI/ML Specialist Solutions Architect at AWS with over 15 years of experience spanning AI/ML, cloud, and software engineering. She specializes in designing and scaling production-grade AI systems, including LLMs, fine-tuning, inference optimization, and enterprise AI architecture across AWS and Google Cloud. Mona is the author of two bestselling books and also a published speaker and researcher who has contributed to leading industry conferences and academic work. She actively mentors professionals in AI and cloud.
Page
5
About the reviewer Sireesha Muppala, Ph.D., is a visionary technology leader with over 25 years of experience driving digital transformation and unlocking the potential of cutting-edge innovations. As a Senior Solutions Architecture Leader at Amazon Web Services (AWS), Sireesha spearheads efforts to empower businesses with the transformative power of generative AI and other emerging technologies. She currently leads a team of dedicated technologists at AWS, focused on partnering with leading organizations in the Automotive and Manufacturing sectors to unlock the full potential of generative AI and other cutting-edge cloud-based technologies. Prior to AWS, she held leadership roles at organizations of all sizes across diverse industries, including Oracle, Blackhawk Network, and Primer AI. Vishnu Elangovan is a Worldwide Agentic Specialist Solutions Architect at AWS, specializing in AI inference, agentic AI distributed systems, and enterprise generative AI applications. With over a decade of experience spanning traditional machine learning and generative AI, he brings deep technical expertise to helping organizations build and scale intelligent systems. Vishnu is a frequent speaker at leading AI conferences, a published thought leader across multiple platforms, and an invited book reviewer. He regularly authors AWS blogs, sharing practical insights on emerging AI architectures and patterns. Outside of work, he enjoys traveling, hiking, outdoor sports, and discovering family-owned coffee shops and wineries.
Page
6
Subscribe for a free eBook New frameworks, evolving architectures, research drops, production breakdowns—AI_Distilled filters the noise into a weekly briefing for engineers and researchers working hands-on with LLMs and GenAI systems. Subscribe now and receive a free eBook, along with weekly insights that help you stay focused and informed. Subscribe at https://packt.link/8Oz6Y or scan the QR code below.
Page
7
(This page has no text content)
Page
8
Table of Contents Preface xv Free benefits with your book ............................................................................... xx Chapter 1: Understanding AI Agents on AWS 1 What is RAG and how does it work? ....................................................................... 2 What are agents? .................................................................................................. 5 Agent capabilities • 6 Exploring the AWS Agentic Stack .......................................................................... 7 Building AI agents on AWS .................................................................................. 10 Progressing from LLMs to multi-agent systems .................................................... 12 Understanding agent protocols ............................................................................ 16 Model Context Protocol • 16 Agent-to-Agent Protocol • 18 Introducing AWS Strands SDK ............................................................................ 20 Building a "Hello World" agent .......................................................................... 23 Setting up your environment in Amazon SageMaker studio • 24 Creating a simple agent • 26 Summary ........................................................................................................... 26 Chapter 2: Building Agents with Tools 29 Technical requirements ...................................................................................... 30 Why do agents need tools? .................................................................................. 30 From function to tool • 33 When one tool isn't enough • 34 Building your first tool-enabled agent ................................................................. 37 The Strands Agents tool ecosystem ...................................................................... 39 Pre-built community tools • 41
Page
9
What's in the toolbox? • 42 Using multiple tools together • 43 AWS integration • 44 Building custom tools ......................................................................................... 46 When simple tools aren't enough • 48 The database connection problem • 48 Slow warehouse checks • 50 Choosing your approach • 51 Quick start with Strands Agent Builder • 52 Building agents on LangChain • 54 Summary ........................................................................................................... 54 Chapter 3: Agent Memory 57 Prerequisites ...................................................................................................... 58 What is agent memory ........................................................................................ 58 Types of agent memory • 60 Challenges with implementing agent memory • 64 Understanding agent workflows with memory • 65 Implementing memory systems with AWS services ............................................. 67 AI agent/LLM • 68 Short-term memory (context) • 69 Structured long-term memory • 69 Semantic long-term memory (the RAG layer) • 69 Durable storage • 70 Memory orchestration • 70 Building a personalized agent with memory ........................................................ 71 Context management and memory optimization for agent memory ..................... 77 Memory optimization • 80 Introducing Amazon Bedrock AgentCore Memory ............................................... 81 Architectural overview of Amazon Bedrock AgentCore Memory ........................... 82 Understanding Amazon Bedrock AgentCore short-term memory ......................... 84 Memory strategies, namespaces, and long-term retrieval in AgentCore Memory .. 86 Table of Contents viii
Page
10
Namespaces • 87 Memory strategies • 87 Memory extraction module • 88 Bringing it all together • 89 Hands-on lab: Using AgentCore Memory with LangGraph ................................... 90 How the integration works • 91 Run the agent • 94 Testing memory persistence • 96 Summary ........................................................................................................... 97 Chapter 4: Advanced Agent Architecture Patterns 99 Technical requirements .................................................................................... 100 When one agent isn't enough ............................................................................ 100 The problem with single agents • 100 The multi-agent solution • 100 What are multi-agent patterns? ......................................................................... 101 Your first multi-agent pattern: the supervisor-worker • 102 The trade-offs of the supervisor-worker pattern • 106 Make agents reusable: agent as a tool • 106 How data flows through multi-agent systems • 110 Understanding communication techniques ........................................................ 112 Sequential communication • 112 Parallel communication • 113 Collaborative communication • 115 Common orchestration patterns ........................................................................ 117 Swarm patterns • 117 Graph pattern • 121 When multi-agent is not the answer .................................................................. 126 Summary .......................................................................................................... 126 Chapter 5: Agent Communication 129 Technical requirements ..................................................................................... 130 ix Table of Contents
Page
11
Model Context Protocol ..................................................................................... 130 Why is a standardized protocol needed for tools? • 130 What problem does MCP solve? • 131 Understanding MCP in action • 133 Differnce between host and MCP client • 135 Managing lifecycle between client and server • 137 Understanding MCP server features • 137 Tools • 139 Resources • 139 Resource template • 139 Prompt templates • 142 Understanding MCP client features • 143 Sampling • 144 Roots • 145 Elicitation • 146 Building and using MCP servers • 147 Using pre-built MCP servers • 147 Building your own or custom MCP Server • 148 Hands-on example of building an MCP server and connecting to an MCP client • 149 Server.py code • 151 Client.py code • 152 Agent2Agent protocol ........................................................................................ 155 Understanding the difference between MCP vs A2A • 155 Why is a standardized protocol needed for agents? • 157 Understanding A2A by an example of a multi-agent system • 158 How A2A architecture works • 160 Understanding A2A data model • 162 Communication styles in A2A • 163 How to implement A2A • 166 Building a multi-agent system with A2A and MCP ............................................. 168 Weather Agent Server • 169 Flights Agent Server • 171 Table of Contents x
Page
12
Travel Orchestrator • 172 Summary .......................................................................................................... 174 Chapter 6: Production Deployment and Enterprise Integration 177 Technical requirements ..................................................................................... 178 What actually changes when you go to production ............................................. 178 Deployment path ............................................................................................. 180 AWS Lambda: Serverless and event-driven • 180 Amazon ECS: Always-on and container-driven • 184 From Lambda handler to web server • 184 What's actually happening on AWS • 185 When to reach for Amazon ECS • 187 Amazon Bedrock AgentCore ............................................................................... 187 The AgentCore architecture • 188 AgentCore runtime • 191 Deployment walkthrough • 195 How runtime compares to Lambda and ECS • 196 AgentCore Gateway • 198 Targets • 199 Semantic search • 200 Authentication: Inbound and outbound • 201 AgentCore Identity • 201 Enterprise integration and industry use cases ................................................... 203 Financial services: Fraud detection at transaction speed • 204 Healthcare: Multi-specialty surgical scheduling • 205 Manufacturing: Predictive maintenance on the factory floor • 206 E-Commerce: Intelligent customer support with specialized agents • 207 Summary ......................................................................................................... 209 Chapter 7: Evaluation, Observability, and AI Governance 211 Technical requirements ..................................................................................... 212 Agent evaluation ............................................................................................... 212 xi Table of Contents
Page
13
Why agent evaluation matters? • 213 Agent evaluation use-case • 213 Relationship between agent observability and evaluation • 215 Evaluation metrics for evaluators • 218 Understating types of agent evaluation • 219 Agent evaluation at a glance • 220 AgentCore Evaluations providing a managed service for evaluations ................... 221 Collecting traces for Agent evaluation via AgentCore Observability • 222 Agentcore evaluation levels • 223 Hands-on using AgentCore evaluations to evaluate travel assistant • 225 Prerequisites: • 227 Step 1: Setup • 227 Step 2: Understand the agent (agent_app.py) • 227 Step 3: Deploy the agent • 228 Step 4: Create a custom evaluator • 228 Step 5: Define test prompts and invoke the agent • 229 Step 6: Wait for traces • 229 Step 7: Run evaluations (3 passes) • 229 Step 8: Summary table • 231 Step 9: Save results • 231 Key insight • 231 Observability: Seeing what your agents do ......................................................... 231 What you need to capture • 232 The OpenTelemetry Foundation • 233 Seeing traces locally with Jaeger • 234 Langfuse • 236 LangSmith: Observability from the LangChain Ecosystem • 239 Connecting Strands to LangSmith • 239 What LangSmith and Langfuse Offer • 240 AgentCore Observability .................................................................................... 241 What gets captured • 241 Exporting to external platforms • 243 Table of Contents xii
Page
14
Putting it all together • 244 Observability anti-patterns • 245 AI Governance: Keeping Agents Within Bounds ................................................. 246 Guardrails: Filtering model outputs • 247 Applying guardrails to a Strands agent • 248 AgentCore Policy: Deterministic control over tool calls • 249 How Cedar policies work • 249 Policies based on user identity • 250 Guardrails and policy • 251 Organizational AI governance: The human layer • 252 Audit trails • 252 Incident response for AI systems • 253 Before you go to production • 253 Summary ......................................................................................................... 254 Chapter 8: Unlock Your Exclusive Benefits 255 Unlock this book's free benefits in 3 easy steps .................................................. 256 Other Books You May Enjoy 260 Index 263 xiii Table of Contents
Page
15
(This page has no text content)
Page
16
Preface This book is a high-level, practical guide to building AI agents on AWS, taking you from core concepts to production-ready systems. It introduces the foundations of agentic AI and explains how autonomous agents, LLM agents, and intelligent agents think, reason, act, and collaborate. You will learn how to design single-agent systems, extend them with tool calling, function calling, and agent memory, and build more capable applications using Amazon Bedrock, Amazon Bedrock AgentCore, the Strands Agents SDK, and LangChain. As the book progresses, it explores how to create stateful agents using Amazon Bedrock AgentCore Memory, enabling more personalized and context-aware experiences. It then expands into multi-agent systems, agent orchestration, and agentic workflows, showing how specialized agents can coordinate to solve complex tasks. You will also learn how emerging interoperability standards such as MCP (Model Context Protocol) and A2A (Agent-to-Agent) support tool integration, agent communication, and more modular, connected agent ecosystems. The book also covers the essential production topics needed to move beyond prototypes. You will understand how to deploy and scale agents with Amazon Bedrock AgentCore and how to improve reliability through agent evaluation, observability, monitoring, governance, and guardrails. This book provides a strong, high-level understanding of how to design, deploy, and operationalize production-ready AI agents on AWS using modern architectures and real- world best practices. By the end of this book, you will be able to design, build, and deploy intelligent, autonomous AI systems that operate reliably at scale on AWS.
Page
17
Who this book is for This book is for AI engineers, machine learning engineers, cloud architects, software engineers, and developers who want to build and deploy autonomous AI systems on AWS. It is also well suited for graduate and undergraduate students who want to enter the agentic AI space. Familiarity with Python, APIs, and basic AI/ML concepts is recommended, but the book is designed to make agentic AI accessible to readers who are still building their foundation. What this book covers Chapter 1, Understanding AI Agents on AWS, lays the foundational groundwork for understanding AI agents on AWS. By deconstructing the evolution of agentic intelligence, it helps you see how systems progress from basic LLMs to sophisticated multi-agent collaborations. It also explores the future of interoperability through emerging protocols like MCP and A2A, which enable agents to share data and collaborate seamlessly across platforms. Chapter 2, Building Agents with Tools, shows you how to turn conversational agents into systems that actually do things. You will start by transforming simple Python functions into agent tools, then explore ready-made tools that can save you days of development time, and finally build custom tools for the unique problems your business faces. Chapter 3, Agent Memory, helps you build multi-agent systems that actually work in production. You will learn to use AWS services like AgentCore Memory and Mem0, and implement different types of memory, including short-term and long-term memory. It also covers context management strategies for building personalized agents that remember user preferences across sessions. Chapter 4, Advanced Agent Architecture Patterns, shows how agents can be orchestrated within multi-agent systems. It explores collaborative agent architectures and design patterns, where multiple agents work together to solve complex tasks Chapter 5, Agent Communication, introduces two important protocols widely used for agent communication: MCP and A2A. You'll learn how to standardize these communication protocols and make agentic systems easier to build, extend, and scale. Chapter 6, Production Deployment and Enterprise Integration, gives practical guidance on deploying agents into enterprise environments. It provides you enough hands-on examples to get your agents running in production. By the end of this chapter, you'll have a clear understanding of choosing the right deployment path and the patterns for connecting your agents to enterprise databases, APIs, and event-driven systems Preface xvi
Page
18
Chapter 7, Evaluation, Observability, and AI Governance, teaches how to evaluate agent behavior, apply security controls and guardrails, improve performance, and instrument agents for visibility across every step of execution. It also explores observability tools such as LangSmith, AgentCore Observability, and Langfuse, along with governance practices that help organizations manage risk, maintain compliance, and build confidence in AI-driven systems. To get the most out of this book This book is designed to be hands-on and implementation-focused, so having the right background and environment will help you get the most out of each chapter. Ensure that you have: Working Strands development environment Basic understanding of Python functions and classes AWS account with access to Amazon Bedrock and permissions for S3, DynamoDB, and Lambda (for AWS integration examples) Familiarity with REST APIs, JSON, and Docker (helpful but not required) AWS CLI and SAM CLI installed (for the Lambda deployment walkthrough) Any IDE like Kiro, Claude Code, or Cursor for development (optional) Download the example code files The code bundle for the book is hosted on GitHub athttps://github.com/PacktPublishing/ Agents-on-AWS. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing. Check them out! Download the color images We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://packt.link/gbp/978-1-80638-721-2. Conventions used There are a number of text conventions used throughout this book. CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example: "In the Jupyter Notebook, open the math-agent-with-checkpointing.ipynb file " • • • • • • xvii Preface
Page
19
A block of code is set as follows: Import LangGraph and LangChain components # Import LangGraph and LangChain components from langchain.chat_models import init_chat_model from langchain.tools import tool from langgraph.prebuilt import create_react_agent # Import the AgentCoreMemorySaver that we will use as a checkpointer Any command-line input or output is written as follows: The EV sector shows strong growth with major players expanding. However, valuations are high and some companies face production challenges. Consider established players like Tesla or Ford over newer entrants. If you have high risk tolerance, the sector looks promising. If you prefer stability, wait for valuations to normalize. Bold: Indicates a new term, an important word, or words that you see on the screen. For instance, words in menus or dialog boxes appear in the text like this. For example: " Each model connects to MCP once, and each tool also connects to MCP once, reducing the integrations to N + M connections." Warnings or important notes appear like this. Note Tips and tricks appear like this. Tip Preface xviii
Page
20
Get in touch Feedback from our readers is always welcome. General feedback: If you have questions about any aspect of this book or have any general feedback, please email us at customercare@packt.com and mention the book's title in the subject of your message. Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you reported this to us. Please visit http://www.packt.com/submit-errata, click Submit Errata, and fill in the form. Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material. If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit http:// authors.packt.com/. xix Preface
The above is a preview of the first 20 pages. Register to read the complete e-book.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
AI guide
# AI Agents on AWS: A Beginner's Guide to Building AI Agents on AWS
## 【One-Line Pitch】
A practical, high-level guide for developers who want to design, build, and deploy production-ready AI agents on AWS—covering everything from core agentic concepts to multi-agent orchestration, memory systems, and enterprise deployment. Ideal for engineers and researchers working hands-on with LLMs and GenAI who need a clear path from prototype to production.
## 【Book Arc】
- **Opening (~0%–10%)**: Introduces the foundations of agentic AI—what agents are, how they think, reason, act, and collaborate—and maps the AWS Agentic Stack, including Amazon Q, Amazon Bedrock, and SageMaker, helping readers choose the right service for their use case.
- **Early (~10%–25%)**: Walks through the Agentic Loop (prompt → model → tools → result) and explains the core architecture: LLM as the brain, tools as the hands, and the agent as coordinator. Includes a detailed breakdown of the Model Context Protocol (MCP) and how it standardizes tool integration.
- **Early (~25%–35%)**: Dives into building agents with tools—covering tool categories (file operations, math, web/search, code execution, AWS services, memory, communication), how to define custom tools with docstrings, and how LLMs handle intent recognition and parameter extraction automatically.
- **Middle (~35%–50%)**: Explores agent memory in depth—short-term working memory vs. long-term storage, AWS service mappings (Redis, Neptune, OpenSearch, S3), and hands-on examples building personalized agents with persistent memory using Strands SDK, Amazon Bedrock Claude, and Mem0.
- **Middle (~50%–65%)**: Introduces Amazon Bedrock AgentCore Memory as a unified platform for automatic memory management, context optimization, and stateful agents, then expands into multi-agent systems, orchestration, and agentic workflows.
- **Late (~65%–100%)**: Covers emerging interoperability standards (MCP vs. A2A), building multi-agent systems with both protocols, and production topics—deployment, scaling, evaluation, observability, monitoring, governance, and guardrails.
## 【Key Takeaways】
- **Agents are more than LLMs** (Early): An agent combines an LLM (brain), tools (hands), memory (context), and planning (strategy). Understanding this four-part architecture is essential before building anything on AWS.
- **The Agentic Loop is the core pattern** (Early): Prompt → model reasoning → tool selection → tool execution → result. This iterative cycle is how agents solve complex tasks, and it's the mental model you'll use throughout the book.
- **Tools replace traditional NLP pipelines** (Early): Instead of writing regex patterns or intent classifiers, you write functions with clear descriptions—the LLM figures out when to call them and extracts parameters automatically. This dramatically simplifies chatbot development.
- **Memory comes in multiple flavors** (Middle): Short-term memory (context window) keeps conversations coherent; long-term memory (vector DBs, key-value stores) enables personalization. AWS offers different services for each: Redis for short-term, Neptune for structured, OpenSearch for semantic, S3 for durable storage.
- **AgentCore Memory automates what you'd otherwise build manually** (Middle): Amazon Bedrock AgentCore provides built-in memory management—compaction, consolidation, and RAG—so you don't have to implement these strategies from scratch.
- **Standardization is the future** (Late): MCP standardizes how agents connect to tools; A2A standardizes how agents talk to each other. Together they enable modular, interoperable agent ecosystems.
- **Production readiness requires more than working code** (Late): Evaluation, observability, monitoring, governance, and guardrails become increasingly critical as agent complexity grows—especially in multi-agent systems where interactions are harder to predict.
## 【Reading Tips】
- **Skim the AWS service overviews** (Early): The AWS Agentic Stack landscape changes rapidly; treat service comparisons as a starting point and consult current AWS documentation for up-to-date capabilities.
- **Deep-read the tool-building chapters** (Early): The hands-on examples—like the inventory-checking agent—are where the concepts click. Try building one of the suggested practice tools (weather, email validation, BMI calculator) to internalize the workflow.
- **Pay attention to the memory architecture tables** (Middle): The mapping of memory types to AWS services (Table 3.2) is a quick-reference you'll want to revisit when designing your own agents.
- **Don't skip the MCP vs. A2A comparison** (Late): This is where the book moves from single-agent to multi-agent thinking. Understanding the difference between tool standardization and agent-to-agent communication is crucial for designing scalable systems.
- **Use the production chapters as a checklist** (Late): When you're ready to deploy, treat the evaluation, observability, and governance content as a pre-launch checklist rather than reading material.
## 【Coverage Limits】
The excerpts cover the book's progression from fundamentals through multi-agent systems and production topics, but detailed code examples for MCP server implementation, A2A architecture specifics, and the full multi-agent weather/flights example are only partially visible in the source material.
##
Passage locations
Excerpt 1
ather Agent Server • 169 Flights Agent Server • 171 Preface This book is a high-level, practical guide to building AI agents on AWS, taking you from core con...
View in text
Excerpt 2
-agent systems, where interactions can be harder to predict. With this understanding, let's deep dive into each stage: 1. LLM: This refers to using a foundat...
View in text
Excerpt 3
ory for PROD-789") agent("Can I order PROD-123 right now?") Each question is phrased differently, but the agent recognizes them all as inventory checks. In t...
View in text
Excerpt 4
dx_576904bethe user's dietary needs and interests. Figure 3.10: Final response generated by the agent after combining user memory with live web search result...
View in text
Recommended for You
{{#thumbnailUrl}}
{{/thumbnailUrl}}
{{^thumbnailUrl}}
{{/thumbnailUrl}}
Loading recommended books...
Failed to load, please try again later
Tip the Site
Scan the WeChat Pay or Alipay code to tip. No login required.
WeChat Pay
Alipay