The Code Codex
Theme
← Notes / AI

note · text21 Oct 2026 · 1 min

Agent harness

The harness is the code that wraps the model and turns it into an agent. The model only takes text in and gives text back; the harness decides what goes in, what to do with what comes out, and when to stop.

Harness

Context

prompt, history, memory

Model

Middlewares

routing, guardrails, logs

Tools

bash, APIs, search

User

Answer

Harness

Context

prompt, history, memory

Model

Middlewares

routing, guardrails, logs

Tools

bash, APIs, search

User

Answer

  • Loop: calls the model, runs the requested tool, feeds the result back and repeats until the task is done.
  • Tools: the actions the agent can take in the world.
  • Context management: what fits in the window, what gets summarized, what gets dropped.
  • Middlewares / hooks: points before and after each step to route models, block dangerous actions, ask for human approval or log what happened.

The same model can do very well or very badly depending on the harness. Many decisions inside it are closed questions (“is this tool dangerous?”, “is it done?”), which opens room for decision models such as JEV.