Skip to content
← Writing

Agent Harness Engineering: When to Build on an SDK vs Buy a Hosted Agent

A practical own-vs-buy guide to the agent harness: what an agent SDK gives you, what a hosted agent service runs for you, and what your team should always own.

Thilak//8 min read

Last updated

Diagram of an AI agent harness: the model in the center, connected to session, sandbox, tools and recovery

An agent harness is the software around a model that turns it into a worker that finishes jobs: session history, tool execution, a sandbox, timeouts and retries, and failure recovery. You can build it on an agent SDK that runs on your compute, or buy a hosted agent service that runs it on the vendor’s compute. Either way, own the parts that encode your judgment: tasks, custom tools, review, budgets and model choice.

I am Thilak. My agents run all day in their own sandboxes and branches, and I have written enough harness glue to know which parts are worth owning. This is the cheatsheet I use.

Key facts

  • SDK = your compute. An agent SDK is a library. The loop, sandbox and session files live wherever you deploy it.
  • Hosted = vendor compute. A hosted agent service runs the loop, sessions and sandbox for you. You send tasks and read events.
  • Anthropic sells both: the Claude Agent SDK and Claude Managed Agents (beta).
  • OpenAI sells an SDK plus hosted tools: the OpenAI Agents SDK and Responses API tools that run in OpenAI-hosted containers.
  • Kimi sells both: a Model Inference API for your own harness and Kimi Hosted Agents.
  • Self-hosted sandbox is not private deployment. The vendor still runs the model and the sessions.

What is an agent harness?

An agent harness is the runtime that wraps a model and keeps the agent loop going. The model decides what to do next; the harness remembers, executes tools, and recovers when something breaks.

Agent loop diagram: context goes to the model, the model makes a tool call, the tool result is appended, then a done check either finishes or loops back to context

Every agent turn: context, reason, call a tool, append the result, check if done.

A while loop around a chat completion is a tiny harness. The loop is the easy part. The hard part is a three-hour run where a tool hangs, the process restarts, and the agent has to resume exactly where it stopped.

What layers does a production harness need?

Five layers: session history, tool execution, a sandbox, timeouts and retries, and failure recovery. Skip one and the agent works in a demo but fails on a long real job.

Diagram of an agent harness: the model in the center, connected to five layers: session history, tool execution, sandbox, timeouts and retries, and failure recovery

The model sits in the middle; the five harness layers keep it running.

Layer Job On an SDK On a hosted service
Session history Store every turn, call, result SDK writes it; you store and back it up Vendor persists it as events
Tool execution Run what the model asks Runs in your process Built-in tools run in the vendor sandbox
Sandbox Isolate code and files You provision the container Vendor cloud sandbox, sometimes self-hosted
Timeouts and retries Keep long jobs moving Your code Vendor runtime
Failure recovery Survive crashes mid-task You checkpoint and resume Vendor resumes the session

SDK vs hosted: what is the difference?

The difference is whose compute runs the loop. Same models either way.

SDK vs hosted diagram: with an agent SDK, your app, the agent loop, sessions, sandbox and tools all run on your infrastructure and only inference goes to the model API; with a hosted agent, your app sends tasks to a vendor cloud that runs the loop, sessions, sandbox and built-in tools, while custom tools run on your side

SDK: you run, store and restart the loop. Hosted: the vendor does.

  • SDK. You deploy the loop. Anthropic’s hosting guide says the Agent SDK “spawns and supervises a claude CLI subprocess that owns a shell, a working directory, and session files on disk”, and recommends running it in a sandboxed container.
  • Hosted. The vendor deploys the loop. Claude Managed Agents is a “pre-built, configurable agent harness that runs in managed infrastructure” (Anthropic docs).
  • Hosted tools are not a hosted harness. A server-side code sandbox runs one tool on vendor compute; your loop can still run on yours.

Who offers what? (official docs, side by side)

Anthropic OpenAI Kimi
SDK on your compute Claude Agent SDK: Python and TypeScript, runs “in a process you operate” OpenAI Agents SDK: agents, handoffs, guardrails, sessions, tracing; uses the Responses API by default Model Inference API, for a custom harness (docs)
Hosted compute Claude Managed Agents: agent loop, tool execution and runtime in managed infrastructure Responses API hosted tools: web search, file search, code interpreter, shell in hosted containers Kimi Hosted Agents: “Harness as a Service”
Status Managed Agents in public beta since April 8, 2026 (announcement) Agent Builder is deprecated and shuts down November 30, 2026 Announced on the Kimi news page
Sessions Server-side event history, streamed over SSE SDK sessions keep history across runs on your side Full history persisted as events
Sandbox Anthropic cloud sandbox or a self-hosted sandbox Code interpreter: “a fully sandboxed virtual machine” Cloud sandbox, or a self-hosted sandbox for enterprise-certified users (docs)
Published price Token rates plus $0.08 per session-hour of active runtime (announcement) Per-container pricing on the pricing page Sandbox hours x ¥0.072/hour, plus inference, plus plugin calls x unit price (pricing)

How to read the table:

  • Anthropic and Kimi both sell the full split: an SDK or inference API for your own harness, and a hosted harness.
  • OpenAI pairs an SDK with hosted tools and containers. I found no current official page for a fully hosted OpenAI agent runtime, so I treat the loop as yours.
  • Prices change. Price one real task on the vendor’s page before you commit.

Should I build or buy an agent harness?

Buy a hosted harness when long-running, reliable execution is the hard part. Build on an SDK when your context strategy (what goes into each prompt) is your edge and you need control over every model call.

Own vs buy decision tree: if long-running reliable execution is the hard part, buy a hosted harness; if context strategy is your edge, build your own; always own tasks, custom tools, review, budgets and model choice

Two questions decide build vs buy; the bottom strip stays yours either way.

Question Lean SDK (build) Lean hosted (buy)
Is context strategy your edge? Yes No
How long do runs last? Minutes, synchronous Hours, async
Do you already run hardened sandboxes? Yes No
Must every byte stay on your infrastructure? Yes Not strictly
Do you swap models per step? Often Rarely
Want to maintain crash recovery? Happy to Please, no

Three hard filters before you sign up for anything:

  • Data residency. A self-hosted sandbox only moves tool execution. Kimi’s self-hosted sandbox docs say the platform keeps handling model calls, orchestration and session management.
  • Compliance. Anthropic’s Managed Agents docs state Managed Agents is not eligible for Zero Data Retention or HIPAA BAA coverage, and transcripts persist until you delete them.
  • Idle cost. Hosted runtimes bill by session or sandbox hours. An agent waiting on a human can still bill, so plan for pauses.

What does a hosted harness take off your plate?

The plumbing. Verified in official docs for the two full hosted harnesses:

  • Session history as events you can pull or stream (Anthropic, Kimi).
  • Cloud sandbox with built-in tools, plus a self-hosted sandbox option (both).
  • Context compaction in the managed harness (Anthropic).
  • Auto-resume after a platform failure (Kimi).
  • Resumable event streams with Last-Event-ID (Kimi quickstart).
  • A skill and plugin catalog: 140+ skills and 30+ plugins (Kimi).

That is roughly the harness backlog I would otherwise write, test and babysit.

What should you still own after buying a harness?

Everything that encodes judgment. Buying a harness rents the engine room; it does not hand over the steering wheel.

  • Task definitions. One scoped task per agent, with clear done criteria.
  • Custom tools. In Kimi Hosted Agents they still run on your client (docs). Auth and blast radius stay yours.
  • Permissions and secrets. Least privilege beats clever prompts.
  • Review. Tests, type checks and a human read of every diff.
  • Budgets. Per-task caps on runtime hours, inference and tool calls.
  • Model choice. Keep an abstraction so a step can move to a cheaper model.
  • Exit path. Copy session events into your own storage.

My rule of thumb: a harness feature that makes review easier matters a lot. A feature that only makes delegation fancier matters much less.

Quick start checklist

  • List your five layers: sessions, tools, sandbox, retries, recovery.
  • Mark each layer “edge” (own) or “plumbing” (buy).
  • Sort tasks into short and sync vs long and async.
  • Decide per vendor: SDK on your compute, or hosted on theirs.
  • Check data residency and compliance before any hosted trial.
  • Price one real task end to end on the vendor’s official pricing page.
  • Confirm where each custom tool runs and with which credentials.
  • One agent per task, one sandbox per agent, one branch per task.
  • Export session history to your own storage.
  • Gate every agent branch on tests, type checks and human review.

Buy the plumbing, own the judgment, and review everything. See how I apply this on my work page and in my products.

Frequently asked questions

What is an agent harness?

An agent harness is the software around an AI model that turns it into a working agent: it stores session history, runs tools, provides a sandbox, and handles retries, timeouts and failure recovery. The model reasons; the harness keeps the agent running.

What is the difference between an agent SDK and a hosted agent service?

An agent SDK is a library that runs the agent loop inside a process you deploy, so you provide the compute, sandbox and session storage. A hosted agent service runs the agent loop, sessions and sandbox on the vendor's infrastructure, and your application sends tasks and reads events over an API.

Which vendors offer both an agent SDK and hosted agent compute?

Anthropic offers the Claude Agent SDK, which runs in a process you operate, and Claude Managed Agents, a managed agent harness in beta. OpenAI offers the OpenAI Agents SDK plus hosted tools in the Responses API, such as code interpreter running in OpenAI-hosted containers. Kimi offers a Model Inference API for custom harnesses and Kimi Hosted Agents, a service that runs the harness for you.

When should I build my own agent harness instead of buying one?

Build your own agent harness on an SDK when you need control over every model call, context strategy and tool loop, or when data must stay on your infrastructure. Buy a hosted agent service when the work is long-running or asynchronous and you do not want to build sandbox, session and recovery infrastructure yourself.

Does a self-hosted sandbox make a hosted agent service a private deployment?

No. In both Claude Managed Agents and Kimi Hosted Agents, a self-hosted sandbox moves tool execution onto your hosts, while the vendor platform still runs the model and manages the agent sessions.

What should a team still own after buying a hosted agent harness?

A team that buys a hosted agent harness should still own its task definitions, custom tools, evaluation and review process, permissions and secrets policy, cost budgets, and the decision about which model handles which job.

GET /blog/agent-harness-engineering-cheatsheet.md · text/markdown
Raw ↗llms.txt ↗
Loading markdown…

This is what AI agents read. Every page on WebTK Dev Studio has a markdown twin: append .md to any URL, sendAccept: text/markdown, or start from /llms.txt.