Harness Engineering 101: The LLM is the brain, the harness is the body
TL;DR Highlight
An agent is a loop managing a JSON array; 16 chapters build one from scratch
Who Should Read
A backend developer who finds agent frameworks magical and wants to understand their internals from first principles
Core Mechanics
- Every turn resends the whole conversation
- LLM APIs are stateless.
- Each turn you send the full conversation as a JSON array and get text back.
- The harness manages that array
- A harness builds, maintains, and protects the array.
- The author sees what the field calls agents as patches on this one loop.
- Each patch exists because something broke
- Each chapter has the same shape: the failure, the minimal patch, what it costs.
- Examples include full context windows, one array not holding all the work, and drift mid-task.
- A ~300-line toy agent grows over chapters
- 16 chapters extend a plain Python agent step by step.
- Runnable code sits in src/harness/, one file per stage.
- Frameworks are wrappers around Chapter 1
- Chapter 10 frames every framework as a wrapper around the JSON array.
Community Reactions
- Building their own harness solved their problems
- A commenter ignored how other agents work and designed around their own pain points.
- They accepted more inference than standard agents and got an autonomous agent they can leave for hours.
- Harness optimization beat raw model strength
- A commenter said Jev was far worse than deepseek raw, but after harness optimization it was much better at a fraction of the cost.
- Counterpoint: the harness can be the brain too
- A commenter listed routing, planners, custom memory, classical ML, and RL as harness-side intelligence.
- They argued some tasks may not need an LLM at all.
- Advice to build it yourself, plus AI-slop criticism
- One suggested starting with Thorsten Ball's how-to-build-an-agent post and writing the core by hand.
- Several commenters criticized the book as AI-written.
How to Apply
- Print your agent's message array today
- Log the messages your agent or framework sends each turn.
- Check how the system prompt, tool results, and history stack up in order.
- Map one failure to a chapter
- Take a recent agent failure (context overflow, drift) and match it to the table of contents.
- Read that chapter's minimal patch first.
- Run the toy harness and change the loop
- Run the staged files in src/harness/.
- Add one tool and see how the loop changes.
Try It
# Paste into Claude or ChatGPT as is (simplified version of the idea)
Assume my agent sends the messages array below to the LLM API every turn.
{{messages JSON or log}}
Analyze it as an array the harness must build, maintain, and protect.
1) Which parts take the most context?
2) Are there ordering issues that break caching?
3) Which patches (summarization, subagents, guardrails) are needed for failures?
Next: ask for the most urgent patch in under 20 lines of Python.Terminology
Related Papers
Same Simulation, Different Evidence: Where Retrieved Tool Output Costs LLM Agents Accuracy
Saving long tool output to files cut GPT-5.1 accuracy by 11.3 points; naming the authoritative file restored it.
Fake News, Real Crashes: Information Injection Attacks on LLM Financial Trading Agents
Fake headlines hijacked LLM trading agents 62% of the time versus 14% for prompt injection.
Harness2 by Google Research – Recursive Agent Harnessing
Recursively refining the harness with fixed model weights raised benchmark scores by up to 11.8 points.
Ousted Savannah police officer gave ICE agent husband access to Flock system
A police officer shared her Flock login with her ICE-agent husband; an audit found 983 searches and she was fired
Tmux and Claude Code: Sessions, Send-Keys, and the Ceiling
Running Claude Code agents in tmux works well, but limits appear around four agents.
Hybrid Reasoning Agents: LLM agents that think in latent space, act through text
Mixing latent reasoning with text tool use cut tokens by up to 54.7% and lifted performance 10.4%.