← All episodes

Sequoia AI series · Episode 02

When to Build Your Own Agent Harness

Harrison Chase, co-founder and CEO of LangChain · ~24 min · Video · Transcript (Whisper) · Previous: Ep 01, Continual Learning

2-minute recap. An agent = harness + model + context, and to own your intelligence you need to own all three. The harness's job is to get the right context to the model at the right time. Almost every agent is the same simple loop (the LLM calls tools until it's done). Harnesses differ in the hooks/middleware they add around that loop, or, at the extreme, in using a fixed cognitive architecture. When to build your own: the further your task is from what the model was trained on, the more you should customize. Even then, keep the parts that are in-distribution (such as the model's native file-edit tool). To improve anything you need evals (benchmarks, with Harbor becoming the standard) and observability (traces). Together they drive a data flywheel: run the agent, collect traces, curate them, experiment, then update the harness, model or context. LangSmith Engine is LangChain's attempt to automate that loop with an agent.

1 · Parts of an agent

Slide: Agent box containing a Harness box which contains Model and Context
Speaker slide — The harness wraps the model and the context. Everything the agent does passes through it.
PartWhat "owning" it means
ModelUse 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).
ContextOwn everything the agent knows: episodic memory (chat history), semantic memory (knowledge via RAG) and procedural memory (skills).
HarnessOwn 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.

Slide: Why do you need a harness? Agents need to work in an environment, connect to your data, manage growing context, parallelize tasks, connect with a human, improve over time
Speaker slide — Six things agents need, and the harness provides each one.

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.

Slide: basic agent loop on the left, and the same loop with middleware hooks before_agent, before_model, wrap_model_call, wrap_tool_call, after_model, after_agent on the right
Speaker slide — Left: the basic loop. Right: the same loop with middleware hooks you can plug code into: before_agent, before_model, wrap_model_call, wrap_tool_call, after_model, after_agent. Claude Code's "hooks and plugins" work the same way.
Example · before_model
Summarization: before each model call, check whether the context is too long, and if it is, summarize it.
Example · wrap_tool_call
Context offloading: when a tool returns a huge result, write it to a file and give the model a short pointer to it instead.
Slide: anatomy of a harness. Execution environment: code interpreter, sandbox, filesystem. Delegation: planning, subagents. Steering: human in the loop. Context management: skills, memory, summarization, context offloading, prompt caching
Speaker slide — Anatomy of a harness, using 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

Slide: two custom cognitive architecture flowcharts, a deep research fan-out and a code review pipeline
Speaker slide — The 2023–24 approach, from when models couldn't be trusted to run in a loop: a fixed flowchart of steps. Left: deep research (generate sub-questions, fan out, write the report). Right: a code-review bot. Most of this has since moved into the harness as loop modifications, but it's still used for very specific flows.

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.

Off-the-shelf harness Claude Code · Codex · deepagents + hooks / middleware same loop, customized Custom cognitive arch. fixed, controlled flow in-distribution · start here out-of-distribution · needs predictability Start general for the fastest time to value, then add gates and checks as you narrow in on the use case you need to be excellent at. Regulated industries like finance often want the right end for control.
My diagram of the spectrum he described. It's a scale, not a yes/no choice.
Key nuance · model profiles
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

Slide: three quotes from Satya Nadella's article The Reverse Information Paradox
Speaker slide — Quotes from Satya Nadella's article "The Reverse Information Paradox": (1) create private evals, because evals define what good looks like in your organization; (2) keep ownership of your memory, traces, feedback, decisions and institutional context; (3) build your own continuous learning loop, a "hill-climbing machine" that compounds the value of your AI investments.
Slide: every company building a mission critical agent will have a benchmark for it; define and catch regressions, hill climb; Harbor is becoming industry standard
Speaker slide — Any company with a mission-critical agent ends up with its own benchmark. It's used to catch regressions and to hill-climb, by changing the harness or the model.

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.

Slide: Harbor evals. Each agent runs in its own sandbox against a task from the dataset
Speaker slide — One sandbox per (agent, task) pair.

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.

Slide: frontier-bench leaderboard comparing agent harnesses and models
Speaker slide — Why benchmarks matter: you can compare harness × model × reasoning effort. Note row 1: a minimal harness (mini-SWE-agent) with Opus 5 beats bigger harnesses. The harness matters as much as the model.
Slide: LangSmith experiments view showing scores, latency and tokens per experiment
Speaker slide — Track more than accuracy. Latency and cost (tokens) matter too.

5 · Observability: why agents fail

Reason 1
The model isn't good enough.
Reason 2 · the more common one
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:

6 · The data flywheel

Slide: a recipe for continuously improving agents. Build a v1 agent, collect lots of traces, curate the trace data, run experiments
Speaker slide — The recipe: ① ship a v1 agent → ② collect lots of traces → ③ curate the traces ("hello data mining") → ④ run experiments. Simple to describe, but hard in practice.
Slide: feedback is crucial for the flywheel. UX design, and synthetic feedback via online evals using SLMs, custom prompting, or code
Speaker slide — The flywheel runs on feedback, from two sources. UX design: nobody clicks thumbs up/down, but a well-designed UX captures feedback implicitly (the same point as Ep 01's "edits, undos, retries"). Synthetic feedback / online evals: judges run over every trace. Running Opus on every trace is too expensive, so use fine-tuned small models (SLMs), cheap models with custom prompts, or plain code when the check is simple.
Curated traces + feedback Harness harness engineering (LangChain) Model fine-tuning (Ep 01's Trajectory) Context memory update whichever part the lesson belongs in
My diagram of a slide that was only visible from the audience camera. It's the same idea as Ep 01's "model vs harness" routing, with memory added as a third target.

Automating the flywheel: LangSmith Engine

Slide: can we automate this? over the four-step recipe
Speaker slide — Steps ③ and ④ take a lot of manual work. Can an agent do them?
Screenshot: LangSmith Engine overview with issues list, issue categories and severity
Demo — Engine is a coding agent that runs in the background with the LangSmith CLI and subagents. It mines traces, groups failures into issues (hallucination, guardrail bypass, wrong tool, …) with links to the supporting traces, and proposes fixes to prompts, context or harness code. Run agent → get traces → spot patterns → fix, done automatically.

7 · Q&A takeaways

QuestionAnswer, 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

TermMeaning
Middleware / hooksCode 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 architectureA fixed flowchart of LLM steps, as opposed to a free-running loop. More predictable, less flexible.
In- vs out-of-distributionWhether a task resembles what the model was trained on, including the specific tools it was trained with.
Context offloadingMoving large tool outputs out of the context window (e.g. into files) and leaving a short reference.
HarborAn open-source eval runner. A task = environment + instruction + tests (verifier) + solution.
Trajectory vs traceA 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 evaluatorA cheap judge (small model, prompt or code) that automatically scores live production traces.
Hill-climbingMaking repeated small changes and keeping only the ones that raise the benchmark score.

9 · When you start building

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.