Skip to content

Harnesses

A harness is the loop that makes an agent behave like an agent instead of a single model call.

It is responsible for the turn-by-turn work around the model: building the prompt, loading memory, selecting tools, handling tool results, streaming responses, persisting messages, and deciding whether the agent should continue or stop.

You can build this loop yourself on top of the Agents SDK runtime, or use an opinionated harness like Project Think.

How harnesses fit

Harnesses sit on top of the Agents SDK runtime:

The runtime answers “where does this agent live and how does it stay durable?” The harness answers “what does this agent do on each turn?”

Choose an approach

Use a build-your-own harness when you need full control over the model call, message format, tool loop, or UI protocol. This is the right approach when you want to compose low-level APIs directly from the Agents SDK.

Use Project Think when you want an opinionated chat-agent harness with defaults for memory, workspace tools, streaming, lifecycle hooks, sub-agent RPC, and durable chat recovery.

Current harnesses

What a harness usually owns

A harness usually owns:

  • Prompt construction — system prompts, memory, retrieved context, and per-turn instructions.
  • Model execution — the call to Workers AI, OpenAI, Anthropic, Gemini, or another provider.
  • Tool orchestration — server tools, client tools, MCP tools, approval flows, and continuation after tool results.
  • Message persistence — how user, assistant, and tool messages are saved and replayed.
  • Streaming and recovery — how responses stream to clients and resume after disconnects or Durable Object eviction.
  • Extension points — hooks before and after turns, steps, tool calls, and recovery events.