Blog

AgentCore Harness or AgentCore Runtime? What we learned building an inbox agent

A single case ID tipped the scales: here’s why we chose AgentCore Runtime over Harness for our inbox agent.
December 3, 2026
Picture of Claudia Müller
Claudia Müller

Senior AWS Consultant

Amazon Bedrock AgentCore gives you two ways to run an agent. The Harness runs the agent loop for you and only asks for configuration. The Runtime runs your own agent code. Start with the Harness to quickly get an agent up and running with full tracing. Switch to the Runtime once your agent needs code of its own, especially if your tools need values that the model must never see.

Two ways to run an agent

An agent is a language model that does more than just answer questions. You give it a goal, a few tools (these days usually made available via MCP, the Model Context Protocol), and a set of instructions, and it works in a loop: think, call a tool, read the result, think again, until the job is done.

Somebody has to run that loop. With AgentCore, you can choose who:

  •  Harness: You describe the agent, and AgentCore runs the loop.

  • Runtime: You write the agent yourself, with or without a framework, ship it as a container image or a .zip archive, and AgentCore runs your code.

Which one fits depends a lot on what your agent has to do. So instead of comparing feature lists, let’s look at a real agent.

Meet the inbox agent

Our agent sits in the operations inbox of a container shipping line. Importers and forwarders write in asking the carrier to release a container for pickup or to accept an empty container back at a depot. Until now, someone on the carrier’s team has answered each of these emails manually.

The agent handles the routine part of that work:

  1. It reads the email and figures out what it’s about.

  2. It looks up the relevant records in the logistics platform: the release request, the drop-off request, and the container.

  3. It checks two things: Does the email clearly approve or refuse something? And does the record actually allow it?

  4. If both are true, it makes the change, for example confirming the release or accepting the empty return at a depot. If the email contains several decisions, the agent makes each corresponding change, but never more than one change to the same record.

  5. If not, it hands the case to a colleague, together with everything it found.

  6. Either way, it writes the reply and a short report of what it did.


The agent does exactly the same job whichever platform runs it, making the two easy to compare. What makes this use case interesting is the combination of two things: The changes are irreversible, because an accepted return can’t be undone. And the input is untrusted, because anyone can send an email.

Not shipping containers? The same shape fits most agents

Swap out a few nouns and you have your own use case:

Our inbox agent

In general

Somewhere else

An incoming email

An external request

A ticket, a chat message, a form, an alert

The shipment record

The system of record

An order, an account, an invoice, a server

Read tools (find a release request)

Lookups

Search orders, read an account, fetch logs

Write tools (accept, reject, confirm)

Actions you can’t undo

Issue a refund, approve a claim, restart a service

The case ID of an email thread

The scope of a single unit of work

A tenant ID, a customer ID, a ticket ID

Handing over to a colleague

Escalation

Assign to a support agent, open an incident

Keep that table in mind. Everything below applies just as much to the right-hand column as it does to our inbox agent.

What doesn’t change: Harness and Runtime alike

A surprising amount of the design is identical on both platforms.

The tools sit behind an MCP Gateway

Both the Harness and the Runtime can reach their tools through an AgentCore Gateway, which serves them as an MCP server. The agent sees a list of tools, and the Gateway forwards each call to whatever backend implements the tool.

That backend can be the only place that holds credentials. With this setup, the model never sees an API key, no matter which platform runs it.

In our agent, a single backend implements every tool, both the ones that look things up and the ones that change something. It’s also the only component that knows the logistics platform’s API token.

Rules belong in the tools, not in the prompt

Since every tool call passes through that backend, it’s also the best place to enforce the rules that really matter:

RuleHow the tool enforces it
One change per record, per requestBefore every write, it checks whether this request has already changed the same record and how many changes it has made in total.
Refusal reasons from a fixed listIt rejects any reason that isn’t on the list.
No internal IDs from the modelIt looks up the record itself.

You can talk a model out of following its prompt. You can’t talk your way past a check in the code that holds the credentials, and that check works exactly the same on both platforms.

In our agent, that means an email can’t change the same record twice, however it’s worded. A rejection reason the model makes up never reaches the platform. And the model never handles a record ID: it provides a reference from the email, and the tool finds the record.

One conversation, one session

Both platforms tie a conversation to a runtimeSessionId. Every follow-up lands in the same session and picks up where the last one left off.

On both platforms, we derive that session ID from the email thread. So when someone replies to a thread, the agent remembers what it looked up and did in response to earlier emails. A Runtime session doesn’t live long enough for email, though: it ends after a few idle minutes. The Harness keeps the conversation for us; on the Runtime, we store it in a DynamoDB table ourselves.

Where the two go their separate ways

The tools and their rules are shared. What’s different is everything around the loop: who runs it, what you build, and how much say you have in what happens.

 

Harness

Runtime

Agent loop

Run by AgentCore

Yours, in any framework

What you build

Nothing, it’s configuration

Your agent code, as an arm64 container image or a .zip package

System prompt

A setting on the Harness

Wherever your code loads it from

Memory

Built in, short-term, and long-term

You wire it up in code

Hooks around the loop

Can allow or deny

Can change things

Built-in tools

A shell, file tools, and a few more (allow only the ones you need)

None, unless you add them

When the caller gets an answer

Streamed as it runs; the caller holds the stream until the end

Whenever your code decides

Allow or deny vs. change

The hooks row is the one you’ll feel most in practice.

Harness hooks fire at four moments: before an invocation, before each tool call, after each tool call, and after the invocation. Each time, they can say allow or deny, and that’s all. They can’t change a tool call’s arguments.

Runtime hooks come from your agent framework (Strands, in our case) and live inside your own process, so they can do whatever your code can do. Rewrite the arguments of a tool call, stop the loop after the final answer, count iterations, keep a record of what the model was thinking between steps.

That looks like an easy win for the Runtime. It isn’t quite as simple, as we’ll see.

The Harness: the quickest way to a working agent

If this is your first agent, start here. There are four good reasons.

Nothing to build

No Dockerfile, no build pipeline, no framework to learn. You write down the model, the prompt, the tools, and a few limits, and AgentCore takes care of the rest. Under the hood, it uses the open-source Strands Agents framework, but you never have to touch it. Changing the prompt is a configuration change, reviewed and deployed like any other.

On the Harness, our whole agent fits into that configuration: the prompt, the tools via the Gateway, the iteration limit, the hooks. If we want it to handle refused releases differently, we edit the prompt file and deploy.

You can watch it think

If you’ve used the original Bedrock Agents, you’ll remember the test pane. You typed a message and immediately saw every step: what the agent reasoned, which tool it called, what came back.

The Harness brings that back. You can test it in the AgentCore console, or locally with the Agent Inspector in the AgentCore CLI (agentcore dev --mode browser), which deploys your project and calls the harness from a local UI. Either way, you see the agent’s reasoning output, every tool call, every result, and the full trace.

Paste a carrier’s reply into the console, and you can follow along as the agent finds the drop-off request, reads it, compares the depot with the email, and makes up its mind. There’s no faster way to learn how an agent actually behaves.

Traces from the very first call

That trace isn’t just a console gimmick. Every Harness invocation produces traces, logs, and metrics on its own, with no extra configuration, starting with the very first call. You’ll find the same view in CloudWatch GenAI Observability for every call your application makes. Two things have to be in place:

What you need

Why

Transaction Search on the account

GenAI Observability reads from there; you enable it once per account.

Active X-Ray tracing on the Lambda function, if one is used to call the Harness

Without it, the function’s calls tell the Harness not to record the trace.

Rules the model can’t argue with

Here the allow-or-deny hooks become an advantage. They run outside the model, so a deny is final, whatever the model has been talked into.

On the Harness, we use this for a draft-only mode. A hook blocks every write tool before it runs, while the agent still reads, decides, and writes up what it would have done. However cleverly an email is worded, it can’t make the agent write anything. On the Runtime, a mode like that is only as solid as the code you write for it.

Where it gets tight

Configuration only goes so far:

  • You can’t run your own code inside the loop. You can only allow or deny.

  • Every value your tools need has to travel through the model, unless you build the Gateway workaround described further down.

  • Whoever calls the agent waits until the run is over, holding a stream open the whole time. You can push that wait out of your application, for example, into a workflow engine that holds the call for you, but the Harness itself can’t accept a request and keep working in the background.

For our inbox agent, the second point was the real problem. When you hit limits like these, it’s time to move on, and AWS makes that easy: agentcore export harness turns a Harness into editable Strands code that you deploy as a regular Runtime agent, precisely so you can go beyond what the Harness configuration allows. Just check the generated EXPORT_NOTES.md, because some things, Gateway tools for example, aren’t wired up automatically.

The Runtime: when your agent needs code of its own

The Runtime removes each of those limits. In return, you build more yourself.

Your code runs the show

You might think a custom image would give you your own code on the Harness, too. The Harness does accept one, but only as an environment for the agent to work in. The harness overrides your image’s ENTRYPOINT and CMD, so your startup code never runs. Your software is simply there for the agent’s shell to use.

On the Runtime, your code is the application, whether you ship it as a container image or a .zip package. You own the entrypoint and everything around the loop.

In our Runtime agent, the entrypoint first claims the email thread, so that two replies to the same thread are never processed at the same time. The second one is turned away and retried a little later. Once the agent is done, the same code generates a summary and a diagram of the case.

Values the model never sees

This is what made the decision for us.

Some values have to reach your tools without going through the model: a tenant ID, a conversation ID, anything that limits what a tool is allowed to touch. If the model passes that value along, a cleverly written request can try to talk it into passing a different one.

 HarnessRuntime
Where the value comes fromThe prompt, so the model has to carry itYour own payload, alongside the prompt
How it gets to the toolThe model passes it as an argument.A hook writes it into every tool call.
Who can get it wrongThe model: a typo, a missing value, an injected oneNobody
Safety netA hook that blocks any call with the wrong value.Not needed

Why can’t the Harness just slip the value in? A few reasons, all from the documentation:

  • Environment variables on a Harness are visible to the agent, and the agent has a shell by default.

  • Hooks can’t rewrite tool arguments.

  • A Lambda tool backend behind the Gateway only receives the tool’s arguments plus some fixed Gateway metadata: gateway, target, tool name, and request IDs. There’s no session ID, no user ID, and no room for your own context.

  • InvokeHarness does accept a runtimeUserId and a W3C baggage header, but nothing in the documentation says either one reaches your tools. And with IAM callers, the harness explicitly doesn’t pass a per-user identity on to them.

There is one way around it, and it lives in the Gateway rather than in the harness. InvokeHarness accepts the tool configuration with every call, and a tool that connects to an MCP endpoint, such as the Gateway’s URL, can carry HTTP headers of its own. So the code that calls the harness can attach the value as a header, which the model never sees and can’t change. On the Gateway, a request interceptor (a Lambda function that runs before every tool call) reads the header and writes the value into the tool’s arguments, overwriting whatever the model put there.

The catch is authentication. A tool configured this way sends fixed headers and can’t sign its requests, so the Gateway has to accept a JWT instead of using IAM (or no inbound auth, with the interceptor doing the check). Your calling code has to fetch a token for every run and pass it along. That’s a second auth setup to build and run, just to get one value to your tools. We haven’t built it ourselves; on paper, it works.

For us, on both platforms, that value is the case ID of the email thread. It decides who gets the reply and which case a write counts against. On the Runtime, the model never sees it, because a hook adds it to every tool call. On the Harness, it has to sit in the prompt, the model copies it into every call, and every now and then it gets it wrong.

If you’re unsure which way to go, ask yourself: is there a value my tools rely on that the model must never be able to choose? In a multi-tenant system, the tenant ID is the classic example. If the answer is yes, you probably want the Runtime.

Code between the model and the result

Hooks that can inject values can do plenty more. Where the Harness gives you a yes or no at four fixed points, the Runtime lets you run real code wherever the loop gives you a hook.

On the Runtime, our agent uses that capability after every model call: a hook stores what the model said it was about to do and why, in our own case record. Each case report can then show the agent’s reasoning output step by step, right next to the tool calls it led to. A Harness hook never sees that text. It only gets the incoming messages, the tool calls and their results, token usage, and the reason the run stopped.

It’s worth separating this from code that lives in the tools. Our tools also do clever things: after confirming a release, for example, the tool reads the container’s status back, because the platform can report success while still holding the container for missing paperwork. If nothing has changed, the report marks the change as not applied instead of done. But that check sits in the tool, so it works on both platforms. What only the Runtime gives you is code around the model: before, between, and after its steps.

Reply right away, do the work later

That leaves the caller waiting for the entire run. On the Runtime, your entrypoint can accept a request, reply within milliseconds and do the actual work in the background, letting AgentCore know it’s still busy. The caller is free right away. A second request for the same conversation still reaches your code, so it’s up to you to turn it away cleanly and have it retried later.

With our Runtime agent, the function that picks up an incoming email hands it over and is done in about a second, even though the case itself takes one to three minutes. On the Harness, the same function would have to stay alive for the whole case.

Traces that speak your language

On the Runtime, owning the code also means owning the traces. You can add a span of your own to every run, attach your own conversation ID to it so you can filter by that ID, and let the framework’s model and tool calls nest underneath. Give it a distinct service.name and your traces never get mixed up with anything else in the account. Every trace of our Runtime agent carries the case ID, so finding out what the agent did with a particular email is a matter of applying a quick filter rather than conducting a long search.

What all this costs you

The price of that freedom is paid exactly where the Harness is strongest. Testing a Runtime agent means sending it a JSON payload and getting back whatever your entrypoint returns. Everything else you have to build yourself: a readable report for each run, a trace with your own ID on it.

The same goes for telemetry. AgentCore publishes its own service metrics and logs for every Runtime agent, but the agent’s traces (model calls, tool calls, reasoning steps) only show up once your code plays along:

What you needWhy
A framework that emits OpenTelemetry tracesStrands does this out of the box.
aws-opentelemetry-distro (0.18.0 or later) in your dependenciesIt exports the traces to AWS.
opentelemetry-instrument in front of your start commandIt hooks in before your code starts.
Transaction Search on the accountGenAI Observability reads from there.
Active X-Ray tracing on the Lambda function, if one is used to call the agentWithout it, the function’s calls tell the agent not to record the trace.

The OpenTelemetry environment variables you’d have to set anywhere else are set by the Runtime itself, so you mainly need to add the package and the start command. With that in place, a framework like Strands traces everything on its own: the agent run, each loop, every model call with its token count, every tool call.

So which one should you pick?

Compare your own use case against the following criteria:

Start with the Harness if…Move to the Runtime if…
this is your first agent and you want to see it work end to end.your agent needs code of its own before, around, or after the loop.
your agent is mostly configuration: a prompt, tools behind a Gateway, rules that boil down to allow or deny.your tools need values the model must never hold.
you want traces and a test console from day one.you want reports and traces built around your domain.

For our inbox agent, the case ID was the deciding factor. A value the model must never get to choose belongs on the Runtime. An agent that only looks things up and answers, like a support bot that hands over anything tricky, would be perfectly happy on the Harness.

Whichever you choose, put the rules that matter in the code that holds the credentials, not in the prompt. It pays off on both platforms, and it makes the move from Harness to Runtime a lot easier when the day comes.

You might also like this

A single case ID tipped the scales: here’s why we chose AgentCore Runtime over Harness for our inbox agent.
Mann in dunklem Hemd sitzt vor einem Computer im Büro mit Bücherregal und Auszeichnungen im Hintergrund
Learn how Microsoft 365 Archive works, what the costs are, and when it makes sense to archive SharePoint content.
Automatic security updates are important, but they aren't enough on their own. Learn why supported operating systems and complementary AWS security services are crucial for protecting your systems.