Predicate Ventures

LangChain Deep Agent Harness: A Production Guide

·5 min read·langchainai-agentsagent-orchestrationllm-evaluationproduction-ai

A deep agent harness is the engineering around the model, not the model itself — and that engineering decides whether the system ships.

Blake Aber · Predicate Ventures


Most agent demos work because they run once, on a curated input, in front of an audience. Production agents run thousands of times a day on inputs nobody anticipated. The gap between those two states is the harness.

A deep agent harness in LangChain is the layer that wraps the model loop: how work gets decomposed, how tools get called, how results get checked, and what happens when any of that goes wrong. The model is a component. The harness is the system.

This piece covers the parts that matter once you move past the demo: orchestration, evaluation, guardrails, cost, and the failure modes that surface only under load.

Orchestration: structure the loop before the model sees it

A deep agent is one that plans, acts, observes, and revises across many steps. Left unconstrained, that loop drifts. The model picks tools it shouldn't, repeats steps, or declares success early.

The first orchestration decision is decomposition. Break the task into sub-tasks the model can reason about one at a time instead of asking it to hold the full problem in context. A planner step that writes an explicit task list, then a worker loop that executes items against that list, outperforms a single open-ended agent on almost every long task.

Keep the planner and the worker separate. The planner produces structure. The worker produces work. Mixing them means the agent re-plans every step and burns tokens re-deciding what it already decided.

Tool boundaries

Tools are where agents touch the real world, so they are where damage happens. Give each tool a narrow signature and validate inputs before execution. A tool that accepts free text and runs it as a shell command is a liability; a tool that accepts a typed, constrained argument is a contract.

Scope tool access per sub-task when you can. An agent step that only needs to read a file should not have write access available. Smaller tool surfaces mean fewer wrong turns and shorter prompts.

State and memory

Deep agents accumulate context fast. Passing the full history to every step is the most common cause of runaway cost and degraded reasoning. Summarize completed work, keep the active sub-task in full detail, and write durable state to an external store rather than the prompt.

Treat the context window as a budget you spend, not a buffer you fill.

Evaluation: you cannot ship what you cannot measure

Agents are non-deterministic, so you evaluate distributions of behavior, not single outputs. A system that works on your last three tests tells you almost nothing.

Build an evaluation set early, before the agent is good. Collect real inputs, including the ugly ones, and label the outcomes you care about. This set is the asset that lets you change prompts and models without guessing whether you improved anything.

Evaluate at two levels. End-to-end evaluation asks whether the agent completed the task. Step-level evaluation asks whether each tool call, each plan, each intermediate decision was correct. End-to-end tells you if something is wrong; step-level tells you where.

LLM-as-judge, with limits

Using a model to grade agent output scales better than human review and is useful for subjective criteria. It is also noisy and can be gamed by the system it grades. Calibrate the judge against human labels on a sample, and never let it be the only gate on anything that costs money or touches users.

Track regressions. Every prompt change, model swap, or tool addition should run against the evaluation set before merge. Agent quality degrades quietly, and the only defense is a test you run every time.

Guardrails: assume the model will try the wrong thing

Guardrails are the checks that sit between the agent's intent and the world's consequences. They exist because the model will, eventually, decide to do something you did not want.

Validate structure first. If the agent is supposed to emit JSON matching a schema, enforce the schema and reject malformed output before anything downstream reads it. Most "agent bugs" are the next step consuming output the model got slightly wrong.

Put hard limits on the loop. Cap the number of steps, the number of tool calls, and the wall-clock time per run. An agent without a step limit is an agent that can loop forever at your expense.

Separate reversible actions from irreversible ones. Reading, searching, and drafting can run freely. Writing, sending, paying, and deleting should require either a confirmation step or a stricter check. Design the harness so the expensive mistake is the one that is hardest to make.

Cost: the loop is the line item

Agent cost is not driven by the model price alone. It is driven by how many times the loop runs and how much context each step carries.

Three things dominate the bill. Context size, because you pay for every token in every step. Step count, because each step is a full model call. And retries, because failed steps often re-run the whole context.

Measure cost per completed task, not cost per call. A cheaper model that takes twice as many steps can cost more than an expensive model that finishes in one pass. Route easy sub-tasks to small models and reserve the large model for steps that need it.

Cache aggressively. Tool results, plans, and partial outputs that don't change between runs should not be recomputed. The cheapest model call is the one you avoid.

Failure modes you will actually hit

The loop that never ends, caused by a missing step cap or an agent that keeps re-trying a tool that will always fail.

The confident wrong answer, where the agent declares success without verifying its work. Add a verification step that checks the result against the original task.

The context collapse, where accumulated history crowds out the actual instruction and the agent forgets what it was doing. Summarize and prune.

The tool cascade, where one bad tool output poisons every subsequent step. Validate tool output before the agent reads it.

None of these are model problems. They are harness problems, and they are solvable with engineering. The model gets better on its own schedule. The harness is the part you control.