You've built an agent that works in isolation. Now you need to run it in production where it handles real users, real money, and real consequences. The gap between a prototype and a production system isn't just scale—it's authentication, permissions, observability, and the ability to know whether your changes actually helped. This lesson walks through a complete architecture that ties together all the components you need.
01Follow one request through the whole platform
Start with a concrete scenario: a customer-support agent where Alice requests a refund for order #4521. Her request flows through eight distinct layers, each solving a specific production problem.
Architecture flowReads top to bottom
Alice: refund order #4521
Cognito / Okta
Login
JWT
1. Runtime
Validates the JWT; its own microVM
2. Memory
Recalls that Alice prefers email
Agent loop
Decides to call the refund tool
3. Gateway
MCP tools/call
4. Policy
Amount under 1000? ALLOW
5. Identity
Fetches a payments-API token
Refund service
Lambda or OpenAPI call
After the call
6. Memory
Saves the event and extracts facts
7. Observability
Traces and metrics
8. Evaluations
LLM-as-judge score
Numbered in request order; memory and telemetry run after the side effect.
Runtime validates Alice's JWT token and routes her to her private microVM. This isolation prevents one user's session from interfering with another's. Memory then retrieves her long-term preferences—in this case, that she prefers email communication. The agent's LLM loop decides which tool to call; that call goes through the Gateway, which routes it to the right service and can coordinate across multiple APIs.
Policy intercepts the refund request and checks whether the amount is under 1000 before allowing it to proceed. Identity fetches the correct API credentials for the payments service. The backend Lambda or OpenAPI service executes the refund. Memory stores the interaction event and extracts structured data. Observability sends traces and metrics to your monitoring system. Finally, Evaluations uses an LLM-as-judge to score whether the agent handled the request correctly.
02Choosing which services to use
You won't need all eight layers for every agent. The decision depends on what problems you're actually facing.
Just need hosting? Runtime alone is enough.
Agent forgets users between sessions? Add Memory.
Connecting many tools or internal APIs? Use Gateway and Registry so teams can share tool definitions.
Agent acts on behalf of SaaS users? Identity supplies the right credentials per user.
Need exact calculations or file processing? Code Interpreter handles that without calling external APIs.
No API available for a data source? Browser can fetch it.
Money or sensitive actions at stake? Policy enforces guardrails; add approval workflows if needed.
Can't see why the agent misbehaved? Observability gives you traces and metrics.
Can't tell if a change helped? Run Evaluations in CI, then Optimization to improve the agent over time.
03Production checklist
Before you ship, work through these non-negotiable items.
Use a separate production endpoint pinned to a tested version. Never deploy directly to the live endpoint.
Build namespaces from authenticated user IDs only. Never use user-supplied input as a namespace key.
Apply least-privilege IAM roles to runtime, gateway, and tool services. Each component gets only the permissions it needs.
Default-deny on Policy for any write or destructive tool. Require explicit approval for refunds, deletions, or transfers.
Set alarms on error rate, latency, and token spend. Token spend is consumption-based, so track it early.
Run Evaluations in CI as part of your test suite. Your rollback plan is reverting to the previous version endpoint.
Review AgentCore pricing and set budgets. Consumption-based billing means you need visibility into what you're spending.
04What to remember
Production architecture has eight layers: Runtime, Memory, Gateway, Policy, Identity, Code Interpreter/Browser, Observability, and Evaluations. You don't need all of them, but you need to know which ones solve your problem.
Isolation and authentication come first. Route each user to their own microVM and validate every token.
Policy is your safety net for high-stakes actions. Default-deny and require explicit approval for anything that costs money or deletes data.
Observability and Evaluations are not optional. You can't improve what you can't measure, and you can't ship what you haven't tested.
AgentCore is consumption-based. Track token spend from day one and set budgets before you scale.
Written and edited by the nexGenCoders team. Spotted a mistake? Tell us and we will fix it.
Don't lose this lesson
Create a free account to save your progress, keep your streak, and work toward a shareable certificate.