How AI Agents Work Under the Hood: Models, Tools, Memory, and Runtime Explained

How AI Agents Work Under the Hood: Models, Tools, Memory, and Runtime Explained

This post breaks down the core components of AI agents—models, tools, memory, and runtime—and explains how they interact to process requests. Using an SRE-focused example on an AWS/EKS retail app, I walk through building an investigative agent from scratch and demonstrate how the pieces fit together on Amazon Bedrock AgentCore and Strands Agents.

Why I wanted to understand AI agents

Getting an AI agent to answer a question is pretty easy. Understanding what's happening behind the scenes is a different story.
Over the last few months, I've been exploring agentic AI and learning about the different pieces that go into building an agent. I read the documentation, went to workshops, and tried out examples. But I still felt like something was missing. I wanted to understand how all of these pieces actually work together.
So I decided to build something myself.
I didn't want to make yet another chatbot. I'm a DevOps engineer, so an SRE use case made sense. It gave me a practical way to play with tools, models, orchestration, permissions, and runtime environments.
For the example environment, I used an AWS retail application running on EKS. I built a small agent that investigates service health using AWS and Kubernetes data. I wrote it from scratch, ran it on my laptop, and then moved it to Amazon Bedrock AgentCore.
But this isn't really a tutorial on building an SRE agent. What I want to get at is what goes into an agent, why each component exists, how the components talk to each other, and what happens when the agent gets a request.
I'll use my own implementation throughout the post to explain these ideas, with the actual code, and show how it all fits together on Amazon Bedrock AgentCore and Strands Agents.

Who is this for

This post is for DevOps engineers, SREs, and developers who are comfortable with AWS and Python and want to understand how an AI agent works. You don't need a machine learning background. It helps to know the basics of IAM, containers, and Kubernetes, because the example agent reads from an EKS cluster.
By the end, you should be able to explain how the parts of an agent fit together, follow a request from the question to the answer, and know the steps for running an agent like this on your laptop and then moving it to AgentCore Runtime.

The roadmap

Here's the order we'll go in:
  1. The building blocks of an agent: model, system prompt, tools, orchestration, runtime, identities, and memory.
  1. The application the agent watches, and the project layout to set up.
  1. One question, start to finish, so you can see how those parts talk to each other.
  1. Each component in detail: Amazon Bedrock, Strands Agents, tools, IAM, and AgentCore Runtime.
  1. From laptop to AWS: the four stages I followed, with the commands.
  1. What comes next: AgentCore Memory, Gateway, and Policy, which I haven't built yet.
  1. Observability and lessons: how to see what the agent did, and what I took away.

A few terms first

  • Agentic AI: software where a language model decides what to do next and uses tools to do it, instead of only answering one prompt. It works toward a goal over several steps.
  • Agent: one of those programs. In this post, an agent is a model plus a system prompt, some tools, and a loop that connects them.
  • Foundation model: a large pre-trained model, such as Claude, that does the reasoning.
  • Amazon Bedrock: the AWS service that lets you call foundation models through an API.
  • Strands Agents: an open-source Python framework that runs the agent loop.
  • Amazon Bedrock AgentCore: a set of AWS services for running agents. This post uses AgentCore Runtime, which hosts an agent as a container, and describes Memory, Gateway, and Policy.
  • Tool: a function the agent can ask to run, such as reading a log or checking a pod.

Table of contents

The building blocks of an agent

Before the code, here's the picture I wish I'd started with. An agent is a handful of parts, and each one has a single job:
  • The model does the reasoning. It reads the question and decides what to do next. It can't touch anything outside the conversation.
  • The system prompt tells the model how to behave: what it's for, what rules to follow, and how to report what it finds.
  • Tools are how the model reaches outside itself. They're functions that read a log, call an API, or query a cluster.
  • The orchestration framework runs the loop. It sends the conversation to the model, runs the tools the model asks for, and feeds the results back until there's an answer.
  • The runtime is where all of this runs. It provides the container and the way to send requests in.
  • IAM identities decide what the agent is allowed to touch.
  • Memory is optional. It lets an agent remember things beyond a single request. My agent doesn't use it yet.
In my project, three AWS-side pieces cover three of those roles:
  • Amazon Bedrock provides the model. The agent sends the conversation and its tool definitions to Claude through Bedrock.
  • Strands Agents is the orchestration framework. It talks to the model, runs the tools the model asks for, passes the results back, and returns the final answer.
  • AgentCore Runtime hosts the agent. It runs my container and sends it requests over HTTP.
The model doesn't automatically know what tools are available or how it should behave. The system prompt gives it the instructions, and the tool definitions tell it what it can call. The model uses both to decide what to do next.
Here's how those pieces connect in my project:


Agent architecture: Bedrock, Strands, tools and AgentCore Runtime

The model reasons, the loop coordinates, the tools act, and the runtime hosts all of it.

The application I'm using

With the big picture in mind, here's what the agent actually works on. It needs something to look at, so I used the AWS retail store sample. It's five services on EKS, each with its own backend:
Service
Backend
 ui 
None (it's the storefront and calls the others)
 catalog 
Aurora MySQL, plus OpenSearch for search
 carts 
DynamoDB
 checkout 
Redis (ElastiCache)
 orders 
Aurora PostgreSQL, plus RabbitMQ (Amazon MQ)
An SRE question about this app touches a lot of different signals: CloudWatch alarms, pod metrics, Kubernetes events, pod status. That makes it a good example, because the agent has to reach outside itself to answer anything.


Application architecture: five EKS services and their backends

The five services and the backend behind each one. The agent never talks to these backends. It reads their alarms, metrics, events, and pod status.

Setting up the project

I'll refer to specific files and code blocks from here on, so here's the layout first. If you want to build along, create this structure now.
The complete code is in the GitHub repository:  nitheeshp-irl/sre-agent . The snippets in this post are excerpts, so clone the repo if you want the full files.

What you need

  • Python 3.12 and Docker, for the container stages later.
  • An AWS account you can experiment in, with AWS CLI credentials set up. I used a non-production account.
  • Access to a Claude model in Amazon Bedrock in your region. I used Claude Haiku 4.5 in  us-west-2 .
  • An EKS cluster running the retail sample app. Without it the tools have nothing to read, though the offline tests still run.
  • The IAM roles from the IAM section: one for tool calls, one for model calls, and one for the runtime. You can create them when you reach that section.

The file structure

sre-agent/
├── agent.py # builds the Strands agent: model, system prompt, tools
├── runtime_app.py # AgentCore entry point (health and agent modes)
├── requirements.txt # Python dependencies
├── Dockerfile # container image for AgentCore Runtime
├── tools/ # plain Python functions, no model involved
│ ├── aws_session.py # assumes the tool, model, and notify roles
│ ├── cloudwatch_logs.py # query_cloudwatch_logs
│ ├── cloudwatch_metrics.py # get_cloudwatch_metrics, get_active_alarms
│ ├── k8s_events.py # fetch_cluster_events, fetch_pod_status
│ ├── service_health.py # get_service_health: the composite check
│ └── report.py # build_report, publish_report
├── tests/ # offline tests that use fake AWS clients
└── deploy/
└── ecr_push.py # creates the ECR repository and pushes the image
The repo also has a  lambda/  folder for the Slack integration and an  injections/  folder of scripts that break the cluster on purpose. Neither is needed to follow this post. There's no  __init__.py  in  tools/  because  agent.py  adds that folder to Python's import path.

Create it

mkdir sre-agent && cd sre-agent
mkdir tools tests deploy
touch agent.py runtime_app.py Dockerfile requirements.txt
touch tools/{aws_session,cloudwatch_logs,cloudwatch_metrics,k8s_events,service_health,report}.py
Put this in  requirements.txt :
boto3>=1.34
botocore>=1.34
kubernetes>=29.0
strands-agents
bedrock-agentcore>=1.25
Then create a virtual environment and install them:
python3 -m venv .venv
.venv/bin/pip install -r requirements.txt

Settings

Two environment variables change how the agent runs, and both have defaults:
export SRE_AWS_REGION=us-west-2
export SRE_MODEL_ID=us.anthropic.claude-haiku-4-5-20251001-v1:0
The code finds your AWS account number on its own, using whatever credentials you're signed in with. It then assumes roles named  retail-app-sre-agent-readonly  and  retail-app-sre-agent-model . If you name your roles differently, set  SRE_READ_ROLE_ARN  and  SRE_MODEL_ROLE_ARN  to their full ARNs.

Where each file shows up

File
Where it appears in this post
 runtime_app.py 
Following one question through the system (the entry point and the two modes)
 agent.py 
Following one question, Amazon Bedrock, and Strands Agents (the model, prompt, and tool wrappers)
 tools/ 
Tools, with  aws_session.py  again under IAM identities
 Dockerfile  and  deploy/ecr_push.py 
AgentCore Runtime, and Stages 3 and 4
 tests/ 
Tools, and Stage 1

Following one question through the system

Say an on-call engineer types  /sre-health checkout  in Slack. That runs the quick health check on the runtime, and for now it's the only command the Slack integration supports.
To ask the agent an open question, such as "Is checkout healthy right now?", you send it to the runtime in  agent  mode. The diagram shows the whole trip, and the steps below walk through it.




The model only asks for tools. Strands runs them and passes the results back. In  health  mode, the entry point skips the agent and the model entirely.

1. The runtime receives the request

AgentCore calls the entry point in  runtime_app.py , which is just a function with a decorator on it:
app = BedrockAgentCoreApp()

@app.entrypoint
def invoke(payload: dict) -> dict:
mode = (payload or {}).get("mode", "health")
if mode == "health":
return _health(payload or {})
if mode == "agent":
return _agent(payload or {})
return {"error": f"unknown mode '{mode}'", "allowed": ["health", "agent"]}
I added two modes because not every question needs a model:
  •  health  mode is the quick check. You send it a service name, and plain Python gathers the alarms, pod metrics, Kubernetes events, and pod status, then applies fixed rules. No model is involved. This is what the Slack  /sre-health  command uses.
  •  agent  mode is for open-ended questions. The request goes through the full agent, so the model decides which tools to call and writes the answer.
Here's how I'd use them together. Say an alarm fires for  checkout . The first thing I want is a fast, predictable answer to "what's the state of this service?", and  health  mode gives me that. But the follow-ups aren't fixed. "Why did it start failing?", "What changed in the last hour?", and "What should I check next?" need someone to decide which logs, metrics, or events to look at based on what the last result showed. That's the point where I'd use  agent  mode.
One honest limit: in my project, nothing triggers  agent  mode automatically. Alarms go to Slack, and the  /sre-health  command only calls  health  mode. I send  agent  requests to the runtime myself. Wiring alarms to the agent is a possible next step, but I haven't built it.
If you don't send a mode, the entry point falls back to  health .
A model is useful when the next step isn't known in advance. "Is checkout healthy?" doesn't have that problem, because the steps are always the same: read the alarms, read the pod metrics, read the Kubernetes warning events, and read the pod status. Plain Python can do all of that.
So a  health  request skips the agent entirely.  _health()  calls  get_service_health() , which gathers that data and applies fixed rules. For example, a firing alarm or a container stuck waiting makes the service  unhealthy .  build_report()  then formats the result. Nothing is sent to Bedrock, so there are no input or output tokens to pay for, and the same data always produces the same answer. That doesn't make the request free, because the runtime still does the work and the CloudWatch API calls have their own small charges. It only removes the model cost.
An  agent  request goes through the full loop, because the question can be open-ended, like "What changed in carts, and what should I check next?" There, the model chooses which tools to call and explains what it finds, and each step in the loop uses tokens.

2. The agent gets a model, a prompt, and tools

For an  agent  request,  agent.py  builds a Strands agent:
model = BedrockModel(
model_id=MODEL_ID,
boto_session=model_session(),
max_tokens=2048,
temperature=0.0,
)
agent = Agent(model=model, tools=TOOLS, system_prompt=SYSTEM_PROMPT, callback_handler=None)
That's really all an agent is at this point: a model, some tools, and instructions. I'm using Claude Haiku 4.5 through Bedrock.

3. Strands sends the question to the model

The question, the system prompt, and a description of every tool all go to Bedrock. The model reads those descriptions and decides what to do next. For our question, it asks for  get_service_health  with  service="checkout" .
This was the part that clicked for me: the model doesn't run anything. It only asks.

4. Strands runs the tool

Strands takes that request, calls my Python function, and sends the result back to the model. In my case, the function reads CloudWatch and Kubernetes using read-only permissions. If the model needs more, it asks for another tool and the loop goes around again.

5. The model writes the answer

The model reads the result and turns it into plain language. My system prompt tells it to cite the tool result behind each claim, to list what it couldn't check, and to never call a service "healthy". The app doesn't publish error rates or latency, so "no problems detected in the signals I can see" is the most it can honestly say.

6. The runtime returns the answer

The entry point returns  {"answer": ...} , and the runtime sends it back to the caller.
That's the whole lifecycle. The rest of this post takes each piece in turn.

What it produced on a real failure

To see all of this working, I broke  checkout  on purpose by pointing it at a container image tag that doesn't exist. The pod went into  ImagePullBackOff , and the alarm for waiting containers fired about two minutes after I made the change. The agent's report then named the service, the pod, and the cause, gave two ways to fix it, and listed the image pull errors from the Kubernetes events. After I rolled the image back, the pod became ready again and the alarm cleared about two minutes later.

Amazon Bedrock: understanding the model

What it is: Bedrock gives you foundation models behind one API. A foundation model on its own isn't an agent. It's the reasoning engine: text goes in, and a decision or an answer comes out. The agent is what you build around it, by giving it instructions, tools, and a loop so it can work toward a goal.
What problem it solves: I don't host or scale a model myself. The agent makes an API call and gets reasoning back.
Why an agent needs it: Without a model, there's nothing deciding which tool to call or how to explain the result. Everything else in the architecture exists to support that decision-making.
Where it appears in my code: In  agent.py , the model ID comes from a single environment variable,  SRE_MODEL_ID , so swapping models doesn't mean touching the code. The  BedrockModel  object uses it:
MODEL_ID = os.environ.get("SRE_MODEL_ID", "us.anthropic.claude-haiku-4-5-20251001-v1:0")
REGION = os.environ.get("SRE_AWS_REGION", "us-west-2")

def build_agent() -> Agent:
model = BedrockModel(
model_id=MODEL_ID,
boto_session=model_session(),
max_tokens=2048,
temperature=0.0,
)
return Agent(model=model, tools=TOOLS, system_prompt=SYSTEM_PROMPT, callback_handler=None)
Model calls run under their own IAM role, which I'll get to below.
I went with the cheapest model that worked. An agent that calls tools and summarizes the results doesn't obviously need the biggest model, though I still want to compare it against a larger one on real failures.

Strands Agents: the loop that connects everything

What it is: An open-source framework for building agents in Python. It's one of several. LangGraph, CrewAI, LlamaIndex, the OpenAI Agents SDK, Google ADK, and Pydantic AI do a similar job, and there are managed options like Amazon Bedrock Agents where you configure the agent in AWS instead of writing the loop.
What problem it solves: Someone has to run the back and forth between the model and the tools: send the conversation, notice that the model wants a tool, run it, send the result back, and repeat. You can write that loop yourself, but it's the same code in every agent.
Why an agent needs it: Because the model only asks for tools and never runs them, something else has to do the running. Strands is that something, and it's also the thing that sits between the model and my code.
Where it appears in my code: The  Agent(...)  line above. You hand Strands a model, a list of tools, and a system prompt, and it handles the rest.
My favorite part is how little it takes to turn a Python function into a tool:
from strands import tool

@tool
def get_service_health(service: str) -> dict:
"""Composite check for one service: alarms, pod metrics, and warning events, with a status
(unhealthy, degraded, no_problems_detected, unknown), the problems found, and the gaps.
Start here for any single-service question."""
return sh.get_service_health(service)
Strands reads the function name, the type hints, and the docstring, and that's what the model sees. So the docstring isn't really documentation anymore. It's the interface. Notice that mine tells the model when to use the tool, not only what it does.

Tools: plain functions you can test without a model

What they are: Ordinary Python functions that reach outside the model.
What problem they solve: A model on its own can only produce text. Tools are the only way it can read a log, check a pod, or query a metric.
Why an agent needs them: They define what the agent can actually do. The model can reason about anything, but it can act only through the tools you give it.
Where they appear in my code: In  tools/ . Here's the start of the first one I wrote:
def query_cloudwatch_logs(service, minutes_back=30, filter_pattern=None, limit=100, client=None):
problem = _validate(service, minutes_back, filter_pattern, limit)
if problem:
return _error(problem, retryable=False)

if client is None:
client = read_only_session().client("logs")
...
Because tools are just functions, I could build and test them before any model was involved. I ended up following three rules for every tool:
  1. Validate every input. The model writes the arguments, so I treat them as untrusted. The log filter only accepts letters, digits, spaces, and a few symbols, which keeps query syntax out.
  1. Return errors as data. A failure comes back as  {"error", "retryable", "hint"}  instead of an exception, so the agent can treat "access denied" differently from "throttled".
  1. Let tests pass in the client. A test can hand the function a fake client, so it runs without AWS. The project has 75 of these offline tests now.

IAM identities: the security boundaries

What it is: Every AWS call runs under an IAM role, and which role it runs under decides what it can do. IAM controls what the agent can reach in AWS. Kubernetes RBAC controls what it can do inside the cluster. In my setup, both boundaries matter.
What problem it solves: An agent's behavior comes partly from a model, and I don't want a model's behavior to be the only thing standing between the agent and my cluster. IAM is a boundary that holds whatever the model decides.
Why an agent needs it: Tools give the agent power, so the question is how much. Separate identities let me give tool calls and model calls different permissions.
Where it appears in my code: I split the agent's work across two roles:
  • Tool calls run as  retail-app-sre-agent-readonly . It can read CloudWatch and describe the cluster, and in Kubernetes it can only view five namespaces.
  • Model calls run as  retail-app-sre-agent-model , which can invoke Haiku 4.5 and nothing else.
 tools/aws_session.py  hands out the right session for each:
def read_only_session():
return _assume(READ_ROLE, "sre-agent-tools")

def model_session():
return _assume(MODEL_ROLE, "sre-agent-model")
Every tool gets its client from one of these functions, which is how the tool-versus-model split stays consistent across the project.
Here's how the boundaries fit together:


IAM and Kubernetes security boundaries

IAM decides what each role can reach in AWS. Kubernetes RBAC decides what the tool role can see inside the cluster.

AgentCore Runtime: where the agent runs

What it is: A managed place to run your agent as a container.
What problem it solves: An agent on my laptop is only useful to me. To let a Slack command or another service call it, it has to run somewhere that stays up and accepts requests.
Why an agent needs it: The loop and the tools have to run somewhere, with credentials and a way to receive input. The runtime provides that environment. It doesn't reason and it doesn't run the loop. It hosts the code that does.
Where it appears in my code: A  Dockerfile , an ECR push script, and one API call. You give AgentCore Runtime an image and an IAM role, and it takes care of running the container and sending it requests. My logs ended up in a CloudWatch log group under  /aws/bedrock-agentcore/runtimes/ .
The image comes from the  Dockerfile  in the repo, and  deploy/ecr_push.py  pushes it to ECR. Creating the runtime is one API call:
c = boto3.client("bedrock-agentcore-control", region_name="us-west-2")
c.create_agent_runtime(
agentRuntimeName="retail_app_sre_agent", # letters, digits, and underscores only
agentRuntimeArtifact={"containerConfiguration": {"containerUri": IMAGE_URI}},
roleArn=RUNTIME_ROLE_ARN,
networkConfiguration={"networkMode": "PUBLIC"},
protocolConfiguration={"serverProtocol": "HTTP"},
)
The runtime gets its own role, which can pull the image, write logs, and assume the two roles above. That's how the identities from the previous section reach the container: the runtime's role is the starting point, and the agent assumes the read-only and model roles from there.
Once the runtime was ready, I called it like this:
client = boto3.client("bedrock-agentcore", region_name="us-west-2")
resp = client.invoke_agent_runtime(
agentRuntimeArn=ARN,
payload=json.dumps({"mode": "health", "service": "carts"}).encode(),
contentType="application/json",
)
I tested  health  mode first. It proves the runtime's identity and the read-only path work without spending anything on tokens. Then I moved on to  agent  mode.

From laptop to AWS: moving from local development to deployment

I built this in four stages. Each stage changes one thing, so when something breaks you know where to look.


Laptop to container to ECR to AgentCore Runtime

The credentials are the main thing that changes along the way: yours on the laptop, then the runtime's role in AWS.

Stage 1: Run the tools and tests on your laptop

If you followed the setup section, your virtual environment and dependencies are already in place. Run the offline tests. They use fake clients, so they need no AWS access:
.venv/bin/python -m unittest discover -s tests

Stage 2: Run the agent on your laptop

Now run  agent.py  with your own AWS credentials. Your credentials only need permission to assume the read-only and model roles, because  tools/aws_session.py  assumes them for each kind of call. The model is picked by  SRE_MODEL_ID , so you can change it without editing code:
.venv/bin/python agent.py "Is checkout healthy right now?"
This is where you fix prompts, tool descriptions, and permissions, because each run takes seconds and nothing is deployed.

Stage 3: Put it in a container and run that locally

AgentCore runs a container, so test the container before AWS does. The  Dockerfile  copies in only the code and installs  requirements.txt . It never copies credentials:
docker build -t sre-agent:local .
docker run --rm -p 8080:8080 \
-e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY -e AWS_SESSION_TOKEN \
sre-agent:local
Passing your credentials in at run time stands in for the runtime's IAM role. The AgentCore SDK serves the entry point on port 8080, so you can send a request to it directly:
curl -s -X POST localhost:8080/invocations \
-H "Content-Type: application/json" \
-d '{"mode": "health", "service": "carts"}'
If that works, the container, the dependencies, and the entry point are all fine. Anything that breaks later is about AWS, not your code.

Stage 4: Deploy to AWS

Deploying takes four steps, in this order:
  1. Push the image to ECR.  deploy/ecr_push.py  creates the repository, logs in, and pushes the image tagged  v1 .
  1. Create the runtime's role. It needs to pull the image, write logs, and assume the read-only and model roles. Those two roles must trust it as well.
  1. Create the runtime with the  create_agent_runtime  call shown earlier. Wait until its status is  READY .
  1. Invoke it with  invoke_agent_runtime , starting with  health  mode and moving to  agent  mode.
What changes between stage 3 and stage 4 is who supplies the credentials. Locally, it's you. In AWS, it's the runtime's role. So if stage 4 fails with an access error while stage 3 worked, look at the role's permissions and trust first.

AgentCore Memory, Gateway, and Policy: what I haven't built yet

Everything above is something I built and ran. AgentCore has three more components that I haven't used in this project. I'm including them because they answer questions an agent runs into as it grows, and I'd rather explain where they fit than leave them as vocabulary from the workshop. What follows is my understanding of what they're for, not experience with them.
Solid lines are what exists in my project. Dashed lines are where I think each component would fit.

Memory

What it's for: Letting an agent remember things beyond the current request, either within one conversation or across several.
The problem it solves: Each request to my agent is independent. It only knows what's in the request and what the tools return right now. That works for "is checkout healthy?", but during a real incident you'd want the agent to remember what it already checked, so the next question doesn't start from zero.
When it becomes useful: When conversations span multiple requests, or when the agent should carry knowledge from one incident into the next. My agent doesn't need it yet because each question stands on its own.

Gateway

What it's for: Exposing tools to an agent through a managed endpoint, so the tools don't have to live inside the agent's code.
The problem it solves: My tools are Python functions packaged in the same container as the agent. That's simple, but it means every agent that wants those tools needs a copy of the code. A gateway is a way to make tools, such as an existing Lambda function or API, available to agents in one place.
When it becomes useful: When several agents share tools, or when the tools already exist as services owned by other teams. With five services and one agent, plain functions are enough.

Policy

What it's for: Checking what an agent is allowed to do before a tool call runs.
The problem it solves: IAM limits what the agent's role can reach, but it doesn't look at the specific request. Policy is about rules on the call itself, such as which tool may be used and with what arguments.
When it becomes useful: When the agent is allowed to change things. Right now every tool is read-only, so the worst a bad call can do is read the wrong thing. If I ever let the agent restart a pod, that's where I'd want a check on the call itself, in addition to the role.
Each of these is another moving part to build and test, so I'm leaving them until the read-only agent has earned more trust.

Observability: seeing what happened

When an answer is wrong, you need to see the path it took. That means seeing which tools the model chose, what they returned, and how the model used the results.
So far I've relied on two things. The runtime's logs go to CloudWatch, and each local run prints a small summary: tokens used, model cycles, and tool calls. CloudTrail is there too if I need to see which role made a particular AWS call.
Those answer different questions. The run summary tells me how much work the loop did. The logs tell me what happened in the deployed runtime. CloudTrail tells me who did what in AWS. An agent is harder to debug than ordinary code because the path changes from question to question, so it helps to have all three.

Observability: CloudWatch Logs, CloudTrail and the run summary

Three views of one run: what the runtime logged, how much work the loop did, and which role called what.

What building it taught me about agent architecture

Building an agent isn't just choosing a model and writing a prompt. Here's how the pieces ended up fitting together for me:
  • The model decides, but it doesn't act. It reads the question and the tool descriptions and asks for what it needs. That was the biggest "oh" moment of the project.
  • The system prompt shapes how it behaves. Mine tells the model to cite the tool result behind each claim and to say what it couldn't check.
  • Tools are the interface to the real world. The model can only be as good as the tools and descriptions it's given, and tools are ordinary code you can test without a model.
  • Orchestration connects the two. Strands runs the loop so the model and the tools never have to talk to each other directly.
  • Permissions set the limits. IAM roles decide what the agent can reach, regardless of what the model asks for.
  • The runtime is just where it runs. AgentCore Runtime hosts the container. It doesn't change how the agent reasons.
  • Memory, gateway, and policy are what come next. They matter as the agent gets longer conversations, shared tools, and the ability to change things.
  • Not everything needs the model. The  health  path is plain Python and gives the same answer every time. Deciding what the model should and shouldn't do is part of the design.
The SRE agent was just the example I used to learn these pieces. Once I'd pulled it apart, the agent stopped feeling like magic: the model makes decisions, the loop carries them out, the roles limit what they can touch, and the runtime gives it somewhere to run. Build each piece on its own, and you end up with something you can actually explain, test, and change.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article