Try Pro free

The Pragmatic Engineer · 4 min · Nov 25, 2026

Durable agent harnesses cut latency, risk, and CPU

The first managed-agent design ran Claude Code inside each sandbox, causing reliability, latency, security, and CPU problems.

The episode’s best minutes

Full analysis
  1. 23:36Shadow traffic made a Rust rewrite verifiable5 min
  2. 47:10Durable agent harnesses cut latency, risk, and CPU4 min
  3. 1:33:42Engineers still need to solve the problems agents depend on4 min
  4. 5 more moments in the full episode
“We could just kind of run a proxy along the side and keep all of our credentials separately in a vault.”
Katelyn Lesseat 50:16 · The Pragmatic Engineer
50:16

Takeaways

  1. Keep the harness durable; spawn sandboxes only when work needs them.
  2. Inject credentials at egress instead of storing them in sandboxes.
  3. The redesign used about one-third as much CPU.

About this segment

The first managed-agent design ran Claude Code inside each sandbox, causing reliability, latency, security, and CPU problems. A durable harness with on-demand sandboxes addressed those issues and used about a third of the CPU.

Katelyn Lesse

Katelyn Lesse is a leads platform engineering at Anthropic.

Leads engineering for Claude’s APIs, developer tooling, and product infrastructure.

  • Gergely Orosz, Host · Host, The Pragmatic Engineer

    Spent four years at Uber heading mobile, web and backend teams; shipped part of its payments system.

From “How Anthropic builds software in 2026 with Katelyn Lesse”, Nov 25, 2026. Watch the full episode

Transcript

From the transcript The Pragmatic Engineer publishes with the episode.

  1. 47:14

    Oh, yeah, yeah, So, okay. So for Managed Agents, the place we started, the first thing we did was we were like, okay, we're going to build this system that's going to run Cloud Agents. And we wanted to do that both for our API customers to be able to build agents, but also for the Cloud Code team. To be able to enable the web and mobile experiences so that you don't have to just cloud code the CLI just like runs on your laptop or the desktop app runs on your laptop.

  2. 47:39

    But we wanted to enable people to be able to fire off cloud code sessions that run in the cloud and you can walk away, right? And come back to it later. And so we, because getting this kind of agent architecture right was so complicated, we figured we would share that part, right? Like we would build this architecture and it would kind of power both. And so what was interesting about it was the first thing that we did, the obvious place to start was great.

  3. 48:03

    An API request comes in, you spawn a sandbox and you boot up cloud code inside that sandbox. And then you've got an agent. The problems that we ran into, the first one was just reliability. I mentioned earlier, like sandbox dies.

  4. 48:15

    And then you have to start from scratch. Yeah. The second was latency in order to actually get any tokens back. You have to wait for the sandbox to boot, and then you have to wait for Cloud Code to boot inside that sandbox, and then you can go talk to the model and then stream those tokens back. So that was a problem. The third was security. We really didn't like this idea that if you boot Cloud Code inside of the sandbox, then whenever you do want to go call tools and external services, you end up needing to have credentials inside that sandbox with the agents that has access to the model, right?

  5. 48:48

    And so that wasn't good. And then lastly, hilariously, CPU was a thing. So we're booting and running a sandbox for every single one of these.

  6. 48:57

    Every one of them uses at least one CPU or more. Right. So we had these four problems.

  7. 49:02

    And we first actually, we launched the Cloud Code web experience in like an early beta. And we launched the API in early beta. And we just weren't happy with any of these problems. And we were kind of trying to scramble to do all the things to individually solve each of these problems. But again, just speaking of things that are possible now that weren't super possible earlier, we ended up going back to the drawing board a bit and saying, what if we, from first principles, redesign and re-architected this thing?

  8. 49:30

    Instead of just doing the easy thing that works, which is boot a box and boot cloud code inside of it, What if we designed this from first principles? And what we ended up with was you would run your harness on a durable server and you would only spawn sandboxes to execute work as needed. And then you'd have your separate session storage. And in that world, you solve for reliability because your harness is on a durable server.

  9. 49:53

    And if any of those sandboxes die, your agent is fine. You solve for latency because the request comes into that durable server and it goes basically straight through to the messages API. And so it's like, The teeniest bit of latency on top of the Messages API, so that was great. Security was solved because the way that we ended up doing this was if you have an agent choosing to call an external system, to call a tool in an MCP server, go out over the internet, We could just kind of run a proxy along the side and keep all of our credentials separately in a vault.

  10. 50:26

    And then when you do go to make that request, you can inject the credential at egress just in time on the way out so that that credential never needs to be Inside of the sandbox. And then CPU was great because we found ourselves running on average around a third of the CPU for this system as the original system. And so we threw the whole thing out and we rebuilt it.