Harness Design Pattern

Harness Design Pattern

A harness is the scaffolding that wraps a model (e.g. Claude) and implements the agentic loop: it assembles prompts, calls the model, dispatches tool calls, and manages conversation state.

The core problem

"Harnesses encode assumptions that go stale as models improve."

When the harness runs inside the execution container, changing the model or loop logic requires redeploying the container. Model capabilities evolve faster than infrastructure, so tightly coupled harnesses become a liability.

The pattern: harness outside the container

Move the harness out of the execution environment. The harness interacts with containers through a minimal interface:

execute(name, input) → string

The container becomes a dumb executor. The harness becomes portable and model-upgradeable without touching execution infrastructure.

Benefits

Relationship to session durability

The harness is now stateless relative to the session — all conversation state lives in the session log. On crash:

  1. New harness instance starts.
  2. Calls wake(sessionId) + getSession(id).
  3. Resumes from last event — no state loss.

Comparison

Concern Harness inside container Harness outside container
Model upgrade Requires container redeploy Harness redeploy only
Container failure Complex recovery logic Error string → model retries
Container lifecycle Long-lived, pre-allocated On-demand
Credential access In-scope (risky) Out-of-scope (safe)