techlist.io

Harness Design

1 posts

Anthropic2026-04-084 min readCurated summary

Scaling Managed Agents with stable interfaces

Anthropic's Managed Agents is a hosted service that runs long-horizon agents through stable interfaces, so the underlying harness, sandbox, and session implementations can change without breaking callers. The design borrows from operating systems, which kept abstractions like `read()` stable while the hardware beneath them changed. Anthropic separates the agent into a session (a durable event log), a harness (the loop that calls Claude), and a sandbox (where code runs), so each can fail or be replaced independently. The result is faster startup, better reliability, and a stronger security boundary. ## Problems with the Coupled Container Design - The first version put the session, harness, and sandbox in a single container. This was simple and let file edits run as direct syscalls, but it treated the server as a "pet." If a container failed, the session was lost, and unresponsive containers had to be nursed back to health. - Debugging was hard. The WebSocket event stream could not show whether a failure came from the harness, a dropped packet, or a dead container. Engineers had to open a shell in the container, which often held user data. - The harness assumed all resources were in the same container. Connecting to a customer's VPC required peering networks or running the harness in the customer's environment. ## Decoupling the Brain, Hands, and Session - **Hands as tools:** The harness no longer runs in the container. It calls sandboxes like any other tool through `execute(name, input) → string`. If a container dies, the harness returns the error to Claude, which can request a new one with `provision({resources})`. - **Crash recovery:** The harness is also stateless. A new harness calls `wake(sessionId)`, retrieves the log with `getSession(id)`, and resumes from the last event. During the loop, it writes durable records with `emitEvent(id, event)`. - **Credential isolation:** Previously, generated code ran alongside credentials, so a prompt injection could expose tokens. Now tokens never enter the sandbox: - Git repositories are cloned during sandbox initialization with the token wired into the remote, so `push` and `pull` work without the agent seeing the token. - MCP tools are called through a proxy that takes a session-scoped token, fetches the real OAuth credentials from a vault, and makes the external call. The harness never sees credentials. ## The Session as an External Context Object - Long tasks exceed the context window, and common fixes like compaction, memory files, and context trimming are irreversible. Once content is discarded, the agent may later need it and be unable to recover it. - The session log stores the full history outside Claude's context window. The `getEvents()` interface lets the harness read positional slices, such as resuming from the last read position, rewinding to see what led up to an event, or rereading context before an action. - The harness can transform fetched events before they reach Claude's context, for example to improve prompt cache hit rates. Anthropic keeps storage in the session and context management in the harness, since future models may need different context strategies. ## Scaling to Many Brains and Many Hands - **Faster startup:** Previously, every session waited for a container to provision and repository to clone, even if it never used one. Now containers are provisioned only when a tool call requires them. Inference starts as soon as pending events are pulled from the log. This cut p50 time-to-first-token by about 60% and p95 by over 90%. - **Many brains:** Stateless harnesses can be started on demand and connected to hands only when needed. - **Many hands:** A brain can use multiple execution environments. Since each hand is just a tool with a name and input, the harness does not need to know whether the sandbox is a container, a phone, or an emulator. Brains can also pass hands to one another. ## Conclusion Managed Agents is a meta-harness: it does not prescribe a single harness design. Its interfaces are opinionated about the surrounding components, namely state (the session), computation (the sandbox), and scaling to many brains and hands, but not about the harness itself. This lets it support Claude Code, task-specific harnesses, and future designs without redesigning the system.