When to Build Your Own Agent Harness
1 · Parts of an agent
| Part | What "owning" it means |
|---|---|
| Model | Use open weights, and be able to switch models. That's both defensive (avoiding lock-in, like being cloud-agnostic) and offensive (using the best model as soon as it's released). |
| Context | Own everything the agent knows: episodic memory (chat history), semantic memory (knowledge via RAG) and procedural memory (skills). |
| Harness | Own the orchestration. Its job: get the model the right context at the right time for the task. That covers fixed context, dynamic context, calling external systems, and feeding what they return back into the loop. |
The model/context rows come from a slide that's only visible from the audience camera, so they're rewritten here as text.
2 · Every agent is the same loop, plus hooks
An agent is an LLM running in a loop calling tools. A request comes in, the model generates, and if it asks for a tool, the harness runs the tool and passes the result ("observation") back. This repeats until the model returns a result. Pretty much every agent today works this way.
before_agent, before_model, wrap_model_call, wrap_tool_call, after_model, after_agent. Claude Code's "hooks and plugins" work the same way.Summarization: before each model call, check whether the context is too long, and if it is, summarize it.
Context offloading: when a tool returns a huge result, write it to a file and give the model a short pointer to it instead.
deepagents (LangChain's model-agnostic, general-purpose take on Claude Code). Every feature is middleware on the same simple loop. Execution environment: code interpreter, sandbox, filesystem. Delegation: planning, subagents. Steering: human-in-the-loop. Context management: skills, memory, summarization, context offloading, prompt caching.The other way: custom cognitive architectures
3 · Build your own harness, or use one off the shelf?
The rule: the closer your task is to what the model was trained on (in-distribution), the better an off-the-shelf harness like Claude Code, the Claude Agent SDK or Codex will work. The further you are out of distribution, the more you'll want to customize.
A task can be out-of-distribution overall while some of its sub-steps are in-distribution. Legal AI is out-of-distribution, but editing files isn't: every lab trained its model with RL on its own file-edit tool, and OpenAI's and Anthropic's differ. So build a custom harness, but use the file-edit tool that matches the model you're running. deepagents handles this with "model profiles", which swap in the right implementation for each model.
→ Customize the overall flow, and keep the in-distribution pieces as close to the model's native tools as possible.
4 · Evals: define what "good" means
Harbor: the emerging standard for running evals
An open-source eval runner from the makers of Terminal-Bench 2. You run an agent (model + harness) against a dataset of tasks, with each task in its own sandbox so they can run in parallel.
What a Harbor task looks like (that slide was only visible from the audience camera, so it's written out here):
my-task/ ├── environment/ Dockerfile / docker-compose: the world the agent acts in ├── solution/ a known-good solution, used to sanity-check the task ├── tests/ ★ the VERIFIER: runs code, unit tests, LLM-as-judge or even agent-as-judge └── instruction.md the prompt the agent receives
Harbor tasks follow the same idea as Ep 01's "make every task rollout-able": a captured start state plus a way to score the outcome.
5 · Observability: why agents fail
The model isn't good enough.
The context the LLM received wasn't good enough. To debug, you need to see exactly what went into the context window, and which steps and tools put it there.
Two views of a run:
- Trajectory: the list of messages (human message → tool calls → reply → next human message), like what you see in Claude Code. Easy to skim.
- Full trace: the complete tree, so you can click into any model call and see its exact inputs and outputs. You need this for real debugging.
6 · The data flywheel
Automating the flywheel: LangSmith Engine
7 · Q&A takeaways
| Question | Answer, in short |
|---|---|
| Do you run Engine on Engine? | Yes. It reports to Slack, and they built Issue Bench (a Harbor-format benchmark) for it. They ran deepagents, Codex and Claude Code on it and found that Codex aggressively wrote itself small scripts to analyze traces, which worked well. They copied that into their own harness (the "Codex-ification of Engine"). → A benchmark lets you borrow what works from other harnesses. |
| Will harnesses converge on one design, or diverge? | "I don't know." General harnesses are now good enough for basic tasks, so start off-the-shelf. Customize more the further out of distribution you go. Labs are converging on coding but differ in small ways (like how files get edited). If one lab specializes in, say, biology, harnesses could diverge. Because things are this unclear, evals and observability matter. |
8 · Glossary
| Term | Meaning |
|---|---|
| Middleware / hooks | Code that runs at fixed points in the agent loop (before or after the model or a tool) to change its behavior without rewriting the loop. |
| Cognitive architecture | A fixed flowchart of LLM steps, as opposed to a free-running loop. More predictable, less flexible. |
| In- vs out-of-distribution | Whether a task resembles what the model was trained on, including the specific tools it was trained with. |
| Context offloading | Moving large tool outputs out of the context window (e.g. into files) and leaving a short reference. |
| Harbor | An open-source eval runner. A task = environment + instruction + tests (verifier) + solution. |
| Trajectory vs trace | A trajectory is the list of messages in a run. A trace is the full tree of every model and tool call with exact inputs and outputs. |
| Online evaluator | A cheap judge (small model, prompt or code) that automatically scores live production traces. |
| Hill-climbing | Making repeated small changes and keeping only the ones that raise the benchmark score. |
9 · When you start building
- Start with an off-the-shelf harness (Claude Agent SDK, deepagents, Codex). Don't build a custom one on day one.
- Turn on full tracing from the first run, so you can see exactly what went into every model call.
- When debugging, blame the context before the model. It's the more common cause.
- Write 20–50 Harbor-style tasks from real use: environment + instruction + test script. That's your private benchmark.
- Track accuracy, latency and tokens together.
- Add cheap online evaluators (code checks first, then small models).
- Customize with middleware (summarization, offloading, your own tool handling) before reaching for a full cognitive architecture.
- Keep the model's native tools (especially file editing) for the model you use.
- Run the flywheel: traces → curate → experiment → update the harness, model or context.
Notes are based on a Whisper transcript. Whisper misheard several names, corrected here: "LinkedIn" → LangChain, "Cloud Code" → Claude Code, "LengSmith" → LangSmith. Slides marked Speaker slide are captured from the video. The other diagrams are my own drawings of slides that were only visible from the audience camera.