🟢 🤝 Agents Published: · 3 min read ·

LangChain: How to build your own agent harness (agent = model + harness)

Editorial illustration: How to build your own agent harness (agent = model + harness)

LangChain published a technical guide that defines the harness as the scaffolding around a model, following the formula agent = model + harness. The central tool is create_agent, which requires a model, tools and a system prompt, and exposes middleware as the primary customization mechanism. The article maps eight common production requirements to middleware types and concludes that 'task-harness fit' decisively determines an agent's effectiveness.

🤖

This article was generated using artificial intelligence from primary sources.

What did LangChain publish?

LangChain published on 3 June 2026 a technical guide by Sydney Runkle explaining how to build your own agent harness. The guide defines the harness as the scaffolding around a language model that connects it to the real world, condensed into the formula agent = model + harness. The harness’s job is to deliver the right context to the model at the right moment for a given task. Without a harness, the model is merely a text generator, and only with it does it become an agent that can act in an environment.

What is create_agent?

The central tool of the guide is LangChain’s create_agent, which requires three inputs to build an agent: a model, tools and a system prompt. The tool is deliberately minimalist, meaning it does not offer a multitude of options but a basic framework that is built upon. Instead of solving customization through numerous parameters, create_agent exposes middleware as the primary customization mechanism, so the agent is built by adding layers around the core rather than changing the core itself.

How does middleware shape the agent loop?

Middleware hooks onto the agent loop at specific points: before and after a model call, before and after a tool call, and at startup and teardown (launching and shutting down the agent). At these points, middleware offers four levers for customization: deterministic logic, tools, custom state and stream handlers. Deterministic logic adds predictable rules, tools extend capabilities, custom state stores data across the loop, and stream handlers manage the flow of output. These levers allow precise shaping of an agent’s behavior without reworking the model.

Which production requirements does the article cover?

The guide maps eight common production requirements to the corresponding middleware types. These requirements are context management, memory, environment interaction, delegation, error handling, policy enforcement, steering and cost control. For each of them, the article shows how to solve it with the appropriate middleware instead of reworking the agent’s core logic. This breaks complex production problems down into modular, reusable components that are enabled as needed.

What does “task-harness fit” mean?

The conclusion of the guide is that “task-harness fit”, that is, the alignment between a task and the harness, decisively determines an agent’s effectiveness. The same model can be an excellent or a weak agent depending on how well the harness is shaped to the specific task. This message shifts the focus from model selection to harness design, suggesting that the quality of an agent often depends more on the scaffolding around the model than on the model itself.

Why does this approach matter for agent builders?

For engineers building agents in production, the guide offers a clear mental model and concrete tools. By separating the agent into model and harness and exposing customization through middleware, LangChain promotes a modular approach in which production requirements are solved by adding layers. The emphasis on “task-harness fit” reminds us that an agent’s success does not come automatically from a powerful model, but from a carefully tailored harness that gives the model the right context at the right moment.

Frequently Asked Questions

What is an agent harness?
A harness is the scaffolding around a language model that connects it to the real world. According to LangChain's formula agent = model + harness, the harness's job is to deliver the right context to the model at the right moment for a given task. Without a harness, the model is just a text generator, and only with it does it become an agent capable of acting.
What is create_agent and what does it require?
create_agent is LangChain's main tool for building an agent. It requires three inputs: a model, tools and a system prompt. It is deliberately minimalist, exposing the main customization through middleware instead of a multitude of options, so the agent is customized by adding layers rather than changing the core.
What is 'task-harness fit'?
Task-harness fit is the alignment between a task and the harness built for it. The article concludes that it is precisely this alignment that decisively determines an agent's effectiveness. In other words, the same model can be a very good or a poor agent depending on how well the harness is tailored to the specific task.

📬 AI news in your inbox

A daily digest built your way — pick topics, sources and cadence. One-click unsubscribe.