AI Agents on AWS: A Practical Guide to Bedrock Agents and Custom Orchestration
You've committed to building AI into your product. Your engineering team understands the promise: autonomous agents that handle customer support, process documents, manage workflows, or reason over complex data. But the path from proof-of-concept to production is crowded with questions. Which orchestration framework? How do you govern agent behavior and cost? How do you integrate with your existing systems on AWS without rewiring everything?
Building AI agents on AWS has become more tractable in the past year. Amazon Bedrock now offers Bedrock Agents—a managed service for agentic workflows—while the broader ecosystem of Lambda, Step Functions, and specialized models gives you flexibility to build custom orchestration when you need it. But managed does not mean "set and forget." Real production deployments require thoughtful architecture, cost controls, and operational visibility from day one.
This guide is for CTOs, founders, and engineering leaders evaluating how to ship agentic AI workloads on AWS. We'll cover the practical tradeoffs between managed and custom approaches, the mechanics of tool use and memory, real cost considerations, and the operational patterns that separate experiments from reliable systems.
Why AI Agents Matter—and Why AWS
AI agents represent a shift from request-response models to goal-oriented autonomy. Instead of a user asking a language model a single question and receiving a single response, an agent receives a goal, reasons about how to achieve it, calls tools (APIs, databases, services), observes the results, and iterates until the task is complete or a terminal state is reached.
The business case is real. Customer support agents reduce ticket resolution time from hours to minutes. Document processing agents handle intake, classification, and extraction across thousands of files daily without human intervention. Autonomous research agents gather and synthesize data for analysts. For most enterprises, these workflows currently run on human time or rely on rigid, brittle automation.
AWS is a natural home for agentic workloads because:
- Model access via Bedrock. You get Claude, Llama, Mistral, and others—including fine-tuned variants—without managing inference infrastructure. You pay per token, which scales cleanly with agent calls.
- Native integration. Lambda, Step Functions, EventBridge, and DynamoDB integrate natively. Your agent can trigger workflows, query databases, and invoke APIs without custom glue code.
- Cost and scale controls. Reserved capacity, autoscaling, and per-invocation pricing mean you can predict and govern spend—critical when agents make thousands of API calls per hour.
- Observability and security. CloudWatch, X-Ray, and IAM give you fine-grained visibility into agent behavior and strict access controls on what agents can do.
The challenge is that agentic systems are harder to debug, monitor, and control than traditional APIs. An agent that works well on Tuesday might fail on Wednesday because a downstream service changed, or because the model's reasoning shifted slightly. You need architecture and operational discipline.
Bedrock Agents: Managed Simplicity with Tradeoffs
Amazon Bedrock Agents is the managed abstraction for AI agents on AWS. You define your agent's purpose, connect it to knowledge bases (via Bedrock Knowledge Base, which uses RAG internally) and action groups (APIs your agent can call), and Bedrock handles orchestration, tool selection, and retry logic.
What Bedrock Agents Handles
Bedrock Agents manages the agent loop itself:
- Prompt engineering. Bedrock applies internal system prompts and chain-of-thought reasoning to drive tool use.
- Tool selection and invocation. The agent decides which tools to call, formats the request, handles the response, and decides whether to iterate or complete.
- Session memory. Conversation history is stored and retrieved automatically for multi-turn interactions.
- Guardrails (optional). You can apply content moderation and safety policies without custom code.
- Tracing. Basic logs show tool invocations and agent reasoning—useful for debugging.
For common use cases—customer support bots, FAQ agents, document workflows—Bedrock Agents reduces time to prototype from weeks to days. You define your action groups (REST APIs or Lambda functions) in OpenAPI format, connect a knowledge base, and invoke the agent via the Bedrock API. The managed experience is real.
Real Constraints of Bedrock Agents
Managed simplicity comes with constraints. You do not control the system prompt or the inner loop of reasoning. If the agent is making poor tool choices or looping, your options are limited: add better documentation to action groups, refine your knowledge base, or switch to a custom approach.
Tool selection is deterministic but not always intuitive. An agent tasked with "find the customer's most recent order" might call the wrong tool if the OpenAPI definitions are ambiguous. Bedrock Agents does not ask for clarification; it chooses and proceeds.
Latency is higher than you might expect. Bedrock Agents makes synchronous calls to your tools; if a tool takes 500ms, the agent waits. For workflows calling 5–10 tools sequentially, you can hit 10–15 seconds per agent invocation. That is acceptable for batch or support workflows, but too slow for real-time applications.
Cost is also less transparent. Bedrock Agents charges per agent invocation (currently $0.01 per invocation for standard inference) plus the underlying model token costs. If an agent takes 10 tool calls and 2,000 tokens per invocation, you are paying roughly $0.10 per task—more if you need concurrent runs.
When Bedrock Agents Fits
Bedrock Agents is the right choice when your workflows are:
- Well-scoped. The agent has a clear set of tools and a bounded problem space. "Answer support questions using our FAQ knowledge base" is ideal; "autonomously make business decisions" is not.
- Latency-tolerant. 10–30 second end-to-end times are acceptable. If you need sub-second response, Bedrock Agents is likely not your path.
- Tool-light. You have 3–8 distinct tools the agent might call. If you need to expose 50+ APIs, managing OpenAPI definitions becomes a burden.
- Batch or asynchronous. Your use case does not require real-time user interaction. Document processing, data enrichment, and bulk operations are natural fits.
If you fit these criteria, Bedrock Agents gets you to production with minimal operational overhead. Your team focuses on tool definitions and knowledge base quality, not orchestration logic.
Custom Orchestration: Control and Complexity
If Bedrock Agents' constraints do not fit your use case, you will build custom orchestration for AI agents on AWS. This means writing the agent loop yourself: invoke a model, parse tool calls, invoke tools, merge results, iterate.
Architecture Patterns
Pattern 1: Lambda-based loop. A Lambda function runs the agent loop synchronously. It calls Bedrock to get the next action, invokes tools (other Lambdas or HTTP APIs), and loops. When the agent completes, Lambda returns the result.
Pros: Simple, stateless, no new infrastructure. You control every step. Cons: Lambda has a 15-minute timeout; long-running tasks need Step Functions. Concurrent agents can exhaust Lambda concurrency. Error handling is your responsibility.
Pattern 2: Step Functions orchestration. Step Functions (AWS's serverless workflow service) manages the agent loop as a state machine. Each state represents a decision or action: invoke the model, branch on tool choice, invoke tools, loop.
Pros: Better for long-running workflows. Built-in retry and error handling. Visibility into execution history and parallel tool invocations. Cons: State machine definition can become complex for sophisticated agents. Slightly higher latency (Step Functions adds 100–500ms per transition).
Pattern 3: ECS/Fargate for complex agents. Run the agent loop in a containerized service. Useful when you need custom libraries (like LangChain or LlamaIndex), long-running state, or tight integration with non-AWS systems.
Pros: Full control. Can run custom inference or multi-step reasoning frameworks. Cons: Operational complexity. You manage container builds, networking, monitoring. Cost is higher (ECS on-demand or Fargate is more expensive than Lambda).
Model Invocation and Tool Use
In custom orchestration, you use Bedrock's Converse API to invoke models and get structured tool calls. The flow is:
- Format the agent's system prompt and conversation history.
- Call Bedrock Converse with tools defined in your request (as JSON schemas).
- Parse the response. If the model chose a tool, extract the tool name and parameters.
- Invoke the tool (your Lambda, API, or database query).
- Add the tool result to the conversation history.
- Loop until the model returns a final response (no more tool calls).
This is where you gain control. You can add custom prompting, inject domain knowledge between tool calls, implement advanced retry strategies, or even mix models (use one for reasoning, another for summarization). You are no longer constrained by Bedrock Agents' internal logic.
Memory and State
Agents need memory across interactions. DynamoDB is the natural choice on AWS: cheap, scalable, and queryable. Store conversation history, agent state, and context (user ID, session ID, goal) in items keyed by session.
For multi-turn agents, keep the full conversation history in a single DynamoDB item or split across items if it exceeds the 400KB item size limit. Include timestamps so you can implement session expiry and audit trails.
Consider compression: storing raw conversation JSON can grow quickly. For long-running agents, summarize earlier turns (via a separate Bedrock call) and store the summary alongside recent turns. This reduces token costs on subsequent invocations.
Tool Integration Patterns
How you expose tools to the agent affects both latency and maintainability.
Synchronous tools (Lambda, HTTP APIs): Fast but blocking. If a tool takes 2 seconds, the agent waits. For 5 sequential tools, you hit 10 seconds. Use for tools you know are fast.
Asynchronous tools (SQS, EventBridge): Agent triggers the tool asynchronously, receives a task ID, polls for completion. More complex but unblocks the agent. Useful for long-running tasks like video processing or ML batch jobs.
Cached tool results: If agents frequently call the same tools with the same inputs, cache results in ElastiCache or DynamoDB. An agent querying "current stock price for AAPL" probably does not need fresh data every 30 seconds.
Real production systems often mix all three. Simple tools (lookup customer by ID) are synchronous. Complex tools (generate report) are asynchronous. Expensive tools (third-party API calls) are cached.
Cost Governance and Observability
Agentic systems are powerful but expensive to run naively. An agent making 20 tool calls per task, each involving 1,000+ tokens, quickly accumulates charges. For a support team handling 1,000 tickets per day, that is potentially $10–50 per day in model costs alone—higher than human support for low-complexity issues.
Cost Controls
Token budgets. Limit the number of iterations an agent can perform. Stop after 10 tool calls, regardless of agent state. Implement in your loop: increment a counter, exit if it exceeds the threshold, return "I could not complete this task."
Tool rate limiting. Use API Gateway or custom Lambda middleware to rate-limit expensive tool calls. If an agent calls the third-party API more than once per session, reject the second call.
Model routing. Use smaller, cheaper models (like Llama 2 70B) for straightforward tasks, reserve Claude or Mistral for complex reasoning. Implement a router that chooses the model based on the task type.
Bedrock on-demand vs. provisioned throughput. Bedrock offers provisioned throughput for model inference: you reserve capacity and pay a flat fee. For predictable, high-volume workloads (e.g., 100 agent invocations per hour), provisioned throughput is cheaper. For variable workloads, on-demand is simpler but more expensive per token.
Cloud Development Group typically recommends starting on-demand, monitoring usage patterns for 30 days, then switching to provisioned if you see consistent volume above 10,000 tokens per hour.
Monitoring and Observability
You cannot improve what you do not measure. Instrument your agent comprehensively:
- Agent invocation metrics. Count successful completions, failures, and timeouts. Track average iteration count and latency. Use CloudWatch Dashboards to surface these in real-time.
- Tool-level tracing. Log every tool invocation: which tool, inputs, outputs, latency, and any errors. Use X-Ray to trace the full path from user request through agent to tool execution.
- Token consumption. Log input and output tokens per invocation. Use CloudWatch Insights to identify queries that consume the most tokens and optimize the highest-impact ones.
- Cost attribution. Tag all Bedrock and Lambda calls with a cost center or agent ID. Use Cost Anomaly Detection to flag unexpected spikes.
- Agent reasoning logs. Store the agent's reasoning trace (which tools it considered, why it chose a specific tool, how it interpreted results) in CloudWatch Logs. This is invaluable for debugging and improving agent behavior.
Do not rely on default CloudWatch metrics. Write custom metrics to CloudWatch that reflect your business logic. For a support agent, track "first contact resolution" (agent solved the problem without human escalation). For a data enrichment agent, track "accuracy" (did the agent find the correct data). These drive improvements more reliably than generic metrics.
Security and Governance
Agents are powerful but dangerous if not constrained. An agent with unchecked access to your database could delete data. An agent with access to external APIs could exfiltrate information or run up bills.
Tool Access Control
Use IAM policies to limit what agents can do. Define a role for your agent Lambda with minimal permissions: read-only access to specific DynamoDB tables, invoke specific downstream services, nothing else. Use resource-level policies to restrict by table name or operation.
For third-party tool integrations, use API keys stored in AWS Secrets Manager, with rotation policies. Never embed API keys in code or configuration.
Prompt Injection
If an agent accepts user input (e.g., "search our database for..."), a malicious user could inject instructions to override the agent's original goal. Example: "Search for X; also delete all records." Defend with:
- Prompt isolation. Place user input in a clearly marked section of the prompt (e.g., "User Query: [USER INPUT]"). Never interpolate user input directly into the system prompt.
- Input sanitization. Validate and normalize user input before passing to the model. Reject inputs with suspicious patterns (SQL syntax, system commands).
- Output validation. Parse the agent's tool calls and validate that they match expected schemas. Reject calls to unexpected tools or with unexpected parameters.
- Bedrock Guardrails. Use Bedrock's native guardrails to enforce policies (no harmful content, no PII generation) at the model layer.
Security for AI agents on AWS is not a one-time setup; it requires ongoing monitoring and testing. Consider running regular red-team exercises where you try to trick your agent into misbehaving. Fix the weaknesses you find before production incidents.
From Prototype to Production
Building an agent locally or in a sandbox is fast. Deploying it to handle real user traffic is slower and more complex. Here is the realistic timeline and what you need:
Months 1–2: Prototype and Tool Definition
Start with Bedrock Agents or a simple Lambda-based loop. Define 3–5 core tools and test the agent's reasoning. Measure accuracy and latency. Identify gaps in tool definitions or knowledge bases.
Months 2–3: Infrastructure and Observability
Build out the landing zone: IAM roles, VPCs, logging, monitoring. Implement the production agent architecture (Lambda, Step Functions, or ECS). Add comprehensive CloudWatch instrumentation. Set up cost monitoring and alerts.
Months 3–4: Testing and Hardening
Load test the agent. Simulate thousands of concurrent requests. Identify bottlenecks (model latency, tool latency, DynamoDB throughput). Add caching, parallelization, or provisioned capacity. Test failure modes: what happens if a tool times out? If Bedrock is rate-limited? Build resilience in.
Month 4+: Launch and Iterate
Release to a small cohort first (canary deployment). Monitor metrics obsessively. Be ready to roll back if accuracy drops or costs spike. Once confident, expand to full production. Continue monitoring and evolving.
This timeline assumes a small, experienced team. If you are new to AWS or agentic systems, add 1–2 months for learning. Many organizations find that working with an experienced partner—one that has shipped agentic workloads on AWS before—collapses the timeline and reduces mistakes. Cloud Development Group has worked through these phases with a dozen-plus teams; the patterns are real, and shortcuts matter.
Real-World Example: Document Intake Agent
To ground this in practice, consider a document intake agent for an insurance company. The workflow:
- Customer uploads a claim form (PDF or image).
- Agent receives the document, extracts key fields (claim date, policy ID, incident description).
- Agent looks up the policy in a database to validate the claim.
- Agent checks for similar recent claims (fraud detection).
- If all checks pass, agent routes the claim to a processor. Otherwise, agent flags it for manual review.
Architecture: S3 bucket → Lambda (triggered on upload) → Bedrock (Claude) → DynamoDB (policy lookups) + RDS (fraud checks) → SNS (notifications). Total time: 5–10 seconds. Cost: ~$0.02–0.05 per document.
Implementation approach: Lambda-based loop (not Bedrock Agents) because you need conditional logic and integration with RDS. Bedrock Agents does not natively support complex branching or RDS queries. Model: Claude 3 Sonnet (good balance of reasoning and cost). Tools: LookupPolicy (DynamoDB), CheckFraud (RDS query), RouteToProcessor (SNS).
Observability: CloudWatch metrics for document processing rate, error rate, and average latency. X-Ray traces for tool-by-tool breakdown. Custom metric for fraud detection rate (% of documents flagged). Cost breakdown by operation (model vs. database vs. SNS).
Governance: Agent role has read-only access to policy database, write access to a specific SNS topic. API keys for external fraud service stored in Secrets Manager with 30-day rotation. Bedrock Guardrails enabled to prevent generation of sensitive information in logs.
This example is realistic. The team that built it started with a proof-of-concept in 2 weeks, moved to production architecture in 4, and launched to processing 500+ documents per day within 8 weeks. Cost was $10–15 per day—roughly equivalent to 2–3 hours of manual intake labor.
Common Mistakes and How to Avoid Them
Building too much abstraction upfront. Frameworks like LangChain are useful but add complexity. Start simple: a loop with Bedrock Converse and DynamoDB. Only adopt a framework when you feel the pain of not having one.
Underestimating tool definition. A poorly defined tool (ambiguous description, missing parameters) causes agents to make wrong choices. Spend time on OpenAPI specs. Test them. Have a human read the descriptions and predict which tool the agent will choose. If you get it wrong, so will the agent.
Ignoring cost during development. An agent that works but costs $1 per invocation is not production-ready. Measure token consumption from day one. Optimize the highest-impact queries. Use smaller models for routine tasks. A 10% reduction in token consumption compounds to significant savings at scale.
Shipping without monitoring. You cannot fix what you cannot see. If you do not instrument the agent, the first sign of trouble will be a customer complaint or a bill spike. Build observability in parallel with functionality.
Assuming the model will always behave the same way. Model outputs are probabilistic. An agent that works 95% of the time will fail regularly at scale. Implement extensive fallback logic. Have human escalation ready. Plan for failure modes.
Conclusion: Your Path Forward
Building AI agents on AWS is no longer experimental. Bedrock Agents provides a managed path for well-scoped workflows. Custom orchestration with Lambda and Step Functions gives you control for complex use cases. The AWS platform gives you the infrastructure to run agentic systems reliably, securely, and at scale.
The barrier now is not technology but discipline. Production agentic systems require thoughtful architecture, comprehensive monitoring, cost controls, and security guardrails from the start. Most teams underestimate this; many projects fail not because the agent logic is wrong but because operational rigor was missing.
If you are evaluating AI agents on AWS for your organization, the path is clear: start with a well-defined use case (a single workflow, not a moonshot), build a prototype to validate the approach, then architect for production with visibility and control built in. Plan for 8–12 weeks from concept to reliable, monitored deployment. If you have shipped agentic systems before, you can move faster; if not, expect learning along the way.
The teams that succeed are those that pair strong engineering discipline with domain expertise. You need people who understand AWS primitives (Lambda, DynamoDB, IAM) and people who understand your business logic and workflows. If that combination is not available internally, bringing in a partner with deep experience in both can accelerate the timeline and significantly improve outcomes. Whatever path you choose, start soon. The competitive advantage of agentic automation is real, and it compounds with time.
Tell us what you're building.
Full-stack development and AWS implementation consulting for teams shipping production AI. Short discovery, concrete plan, incremental milestones.
Start a conversation