
Why they built Engine
LangSmith calls itself the home of the agent improvement loop, with four pillars: build, test, deploy and monitor. The trouble starts as you grow: the more agents you deploy, the more traces they generate, and the more time you spend sorting through them by hand to find where your agent went wrong.
Some failures are easy to catch. A tool error stands out, and the overall trajectory is visible in the trace view. But others only show up when you inspect each trace closely:
- the agent loops through the same tool calls;
- it passes the wrong arguments to a tool;
- it takes inefficient detours;
- it misses a tool it should have used;
- it fails the same kind of request over and over, run after run.
LangChain ran into this with its own agents, and that's why they built Engine. It has three jobs:
- Find recurring failures in traces.
- Turn those failures into actionable issues.
- Turn those issues into durable improvements: evaluators, dataset examples and fixes.
And Engine is itself an agent: an orchestrator that uses specialized components to run that loop end to end. It pulls traces, reads code when a repository is connected, groups failures into issues, proposes evaluators and examples, and keeps updating what it knows about your agent.
What it produces: issues
At its core, Engine finds issues. An issue is a recurring failure pattern, backed by traces that prove it, with proposed actions to deal with it. They all show up on the Issue Board: the list of problems Engine has found in your tracing project.
Every issue has seven fields:
- Name and description.
- Category, from a fixed list of typical agent failures.
- Severity: low, medium or high.
- Traces that serve as evidence of where it happens.
- Proposed actions to keep it from happening again.
- Tags that drive follow-up workflows, like
needs_fix.
The proposed actions come in three kinds:
- An online evaluator, which would flag the failure if it happens again.
- Dataset examples for offline testing that represent the failure.
- A fix: changes to the code or the prompt.
The key point, according to the article, is that Engine doesn't just point at a bad trace. It tries to turn a production failure into something your team can act on and test against in the future.
What it consumes
Engine receives, or can fetch, four inputs:
Instructions: the Agent Overview. It's similar to an AGENTS.md file: a living description of what your agent does, what its traces look like, which failures to watch for and what your team prefers. The first run is bootstrapped from your answers to some onboarding questions and the project context; during it, Engine analyzes traces and uses what it learns to write the first version of the Overview. On later runs, the Overview is a persistent input that Engine reads and updates. You can also edit it by hand at any point.
Traces. Engine pulls them from the LangSmith project through the LangSmith CLI. A full trace holds the messages and trajectory of an agent run. But for scale, Engine doesn't always start by loading every trace in full: it often starts from compact trajectory summaries and only loads full contents when a trace needs a deeper look.
Existing issues. Engine fetches the current issues, both open and previously closed. That gives it the state of the project: it avoids duplicating known issues, adds evidence to open ones and knows what has already been resolved.
The codebase, optionally. If you connect your repository, it's installed into the sandbox, and during setup you choose which branch or subdirectory to use. With the code, Engine diagnoses more precisely, and a separate fix agent can propose changes.
What it updates
Issues. This is its main role: creating new issues, updating existing ones, attaching evidence traces and changing their metadata. For each one, it can propose an evaluator that catches the same pattern in future traces, regression examples drawn from the evidence traces (so a production failure becomes offline test coverage), and prompt or code changes.
The Agent Overview. Engine takes notes on what it discovers and saves them there for future runs. That's how it remembers project-specific things over time: common failure modes, trace patterns, tool behavior and user preferences.
The architecture
Engine is built on Deep Agents and connected to a sandbox, where it can write files, inspect traces, run code and work with a checked-out repository. Six pieces drive it:
- The system prompt and instructions, including the Agent Overview.
- The sandbox, the environment where it works.
- The LangSmith CLI, its main interface for fetching data and pushing updates back to LangSmith.
- Custom tools, especially for testing evaluators and proposing regression examples.
- Subagents, to screen traces and investigate likely issues without overflowing the main agent's context.
- Memory, kept in the Agent Overview and updated from what users do.
At its heart is a six-step loop, which the rest of the article (and this post) follows:
- Prepare the agent's context.
- Screen traces at scale.
- Investigate likely issues.
- Create issues, evaluators and dataset examples.
- Hand off fixes to a separate agent when needed.
- Update memory for the next run.
1. Preparing the context
Before analyzing anything, Engine needs an environment to work in and enough context to understand the agent it's inspecting.
The sandbox. Engine runs connected to a LangSmith sandbox (LangSmith Sandboxes). Before it starts, the base Engine Docker image is pulled, with the required libraries and the LangSmith CLI. If a GitHub repository is connected, the code is pulled down too, from the branch or subdirectory you chose. The sandbox matters because Engine needs to inspect trace data, write intermediate files, test evaluator code and iterate on what it proposes. A controlled working environment makes all of that much more reliable.
The Agent Overview is both an instruction file and a memory layer. When you set up Engine you answer some basic questions; from those answers and what it finds on its first run, it creates the initial version. From then on it keeps a running record of what your agent does, what its traces look like, which pitfalls to watch for, the project context and user preferences. It reads and updates it on every run.
The LangSmith CLI. To talk to LangSmith, Engine mostly uses the CLI, instead of a custom tool for every operation. The CLI gives it a general-purpose interface for pulling traces, querying and creating issues, attaching traces, updating metadata and proposing artifacts. And there's another upside: it's the same CLI you can download and hand to coding agents locally. If Engine does something through it, you can usually understand and reproduce that operation outside Engine, which makes debugging much easier.
2. Screening traces at scale
According to the author, the biggest architecture challenge was trace volume. Getting an agent to investigate and sort through 50 traces at a time was relatively easy. But once they connected it to production agents, those techniques fell apart: a real project can have thousands or tens of thousands of traces in its lookback window. And just ten traces from long-running agents can hold hundreds of tool calls and messages.
Loading all of that into the main agent's context isn't viable, so they split the problem into two phases:
- A broad screening phase that quickly spots suspicious traces.
- A deeper investigation phase that only loads full context for traces that are likely to matter.
The trajectory: a trace's skeleton
To make screening possible, they needed a compressed representation of each trace. The article's question is a good one: how do you compress the information in a trace while keeping what you need to navigate back into it?
The answer was the agent trajectory: a compact skeleton of the trace. It has one entry per turn, with the role, the tool name if there is one, the latency and the content size. But not the content. This is the article's example:
{ role: "human", chars: 142 }
{ role: "ai", latency_ms: 1820, chars: 89 }
{ role: "tool", tool_name: "search_db", latency_ms: 340, chars: 2100 }
{ role: "tool", tool_name: "search_db", latency_ms: 312, chars: 1980 }
{ role: "tool", tool_name: "search_db", latency_ms: 298, chars: 2040 }
{ role: "ai", latency_ms: 2100, chars: 210 }Without reading a single word, the shape already looks suspicious: three calls in a row to search_db, each with around 2,000 characters. The trajectory works as a map: the screener spots odd shapes (repeated tools, long gaps, large outputs, excessive steps), greps around the full trace and loads only what it needs into context.
Traces with feedback go first
Many traces already carry feedback: human annotations, LLM-as-a-judge scores, or end users' thumbs up or down. Engine treats it as a high-priority signal that an issue may exist. The first traces it pulls include those stats, and it's told to look at the ones with feedback first. But feedback doesn't automatically become an issue: it raises the priority for screening and investigation, and the agent still has to decide whether the trace is part of a real problem.
The screener subagent
Screening asks a single question: given this trace, is there something in it worth investigating? To answer it, Engine uses a dedicated, Haiku-based screener subagent, which the main agent dispatches across groups of about 20 traces.
Its job is narrow on purpose. It doesn't create issues. It doesn't diagnose root causes. It only decides, at a surface level, whether a trace is clean or might have a problem. It returns a structured response to the main agent: one line per flagged trace, with its ID, category and a short reason, followed by a count of clean traces. This is the format the article shows:
<trace_id> | <category> | <one-line reason>
CLEAN: 47(The 47 is just the article's format example, not a result: with groups of about 20 traces, a screener couldn't return 47 clean ones.)
With several screeners running in parallel, the search space shrinks: instead of asking the main agent to reason over every full trace, it only looks at the ones that deserve more attention.
3. Investigating
After screening, the main agent reads the screener outputs and dispatches deeper investigations. The investigator takes the flagged traces, pulls their full contents, reads the codebase when available and analyzes the potential issue. Subagents do this because full traces can be huge: loading several of them, plus the relevant code, into the main agent's context would overflow it quickly.
Unlike the screener, the investigator isn't a dedicated subagent with a fixed system prompt. It's a general-purpose subagent that the main agent prompts for each specific investigation. That gives the main agent flexibility, since different issue types may need different strategies. The investigator's job is to decide whether the flagged traces are a real issue, whether they should be grouped together, and what should be recorded on the issue.
Constrained categories
Every issue has a category. The team defined a list of common agent failure modes and prompts Engine to look primarily for those. Some examples from the list:
pii_leakagent_loopingincorrect_tool_argsmissing_tool
Constraining the categories lets them control what Engine finds and evaluate each type before introducing it to customers, and it makes the output easier to understand. Teams can still describe their own priorities in the Agent Overview. And the list keeps growing as they identify and validate new recurring failure modes.
4. Issues, evaluators and examples
When it finds a real issue, the main agent creates or updates it and attaches the evidence traces. It's responsible for the issue and the evaluation artifacts around it, but not for fixing the code or the prompt. For each issue it can produce:
- The issue itself, with evidence traces.
- A proposed evaluator.
- Proposed regression examples.
- A
needs_fixtag, if a separate fix agent should be kicked off.
Two kinds of evaluators
Engine is prompted to propose an evaluator for every issue. The idea is simple: once you find a failure pattern, you want a check that catches it in future traces. There are two kinds:
- Code evaluators: JavaScript functions that inspect a trace's structure (field values, tool outputs, step counts, error patterns). They fit when the failure can be detected without reading the content.
- LLM-as-judge evaluators: for cases that need understanding, like hallucinations, grounding failures, unhelpful refusals or bad advice.
The agent picks based on the issue: structural failures get code evaluators; semantic failures get judges.
Testing the evaluator before proposing it
An evaluator can look reasonable and still miss the actual issue. So before showing one, Engine calls the test_evaluator tool with the evaluator definition and the traces it wants to run it on. The tool runs it and returns a result per trace:
def test_evaluator(evaluator, traces) -> {run_id: PASS | FAIL | SKIPPED}PASS caught issue
FAIL missed issue, or evaluator errored
SKIPPED evaluator did not apply to this traceIf the evaluator doesn't catch the right traces, Engine iterates on the code or the prompt. The goal is to ship the version that best captures the failure pattern the evidence traces represent.
Regression examples with assertions
Whenever it creates an issue or adds a new trace to one, Engine calls propose_regression_example once per evidence trace. That proposes a regression example: the original input to the agent, along with assertions about the expected output.
They propose assertions rather than a full ground-truth output because assertions are simpler and more flexible: a correct response can be phrased in many ways, and what matters is whether it satisfies the key claims the trace implies. Each assertion has a key (a short slug) and a comment (a one-sentence, human-readable claim a correct response must satisfy). The article's examples:
{
"key": "must_cite_max_connections_4096",
"comment": "Response cites the max_connections value of 4096 returned by the get_config tool call."
}
{
"key": "must_not_reference_strict_mode_flag",
"comment": "Response must not suggest enabling strict_mode, which was deprecated in this version."
}
The proposed examples show up on the issue, and a reviewer can promote them into a dataset. That closes the loop: a production failure ends up as offline test coverage.
5. Fixes, handed to another agent
A key design decision was separating issue creation from fix generation. In earlier versions, the main agent did both: scanning traces, deciding what mattered, grouping failures, creating issues, generating evaluators, proposing examples and also reasoning about the right fix. That job was too broad, and they saw the main agent struggled to identify fixes reliably when all of it happened in one pass.
So they split the workflow:
- The main Engine agent identifies and records the issue.
- It creates the dataset and evaluator artifacts.
- If the issue needs a fix, it adds a
needs_fixtag. - A separate fix agent is kicked off to propose the actual code or prompt change.
The main agent gets simpler, and the fix agent gets a more focused task: it starts from the issue, its evidence traces and the connected repository, without having to run the whole screening workflow.
6. Memory
Engine doesn't start from scratch every time. The Agent Overview is updated not only by its investigations but also by what users do: when you resolve an issue, close one or create an evaluator, that action becomes a signal.
Engine pulls recent events through the LangSmith CLI, generalizes from them and updates the Overview. It's specifically prompted to maintain a User Preferences section, recording what it learns from how users interact with issues. Every team cares about a different set of problems, and the Overview is how Engine adapts its analysis to those preferences over time.
The lessons
The article closes with the architecture decisions that ended up mattering most:
- Keep the main agent focused on issues. It creates issues and their evaluators and examples; fixes go, via
needs_fix, to another agent. - Use the CLI as the main LangSmith interface. More flexible than a narrow custom tool for every operation, and easier to reproduce and debug.
- Compress traces before reading them. Trajectories let Engine reason over the shape of many traces and then load only the details that matter.
- Split screening from investigation. Screening optimizes for scale; investigation, for depth. Not every trace has to go through an expensive investigation.
- A dedicated screener, flexible investigators. Screening is narrow and repeatable, so it benefits from a fixed prompt and structure; investigations vary (reading code, understanding evaluator failures, comparing traces), so they use general-purpose subagents prompted on the fly.
- Constrain issue categories. Letting the agent invent categories makes the output harder to evaluate and harder to trust. A fixed taxonomy lets them control quality, measure performance and expand coverage deliberately.
- Prefer assertions over full expected outputs. They pin down what must be true without over-constraining the wording of a correct response.
In short
The hard part of agent observability isn't seeing what happened in one trace. It's finding the patterns that repeat across many, deciding which ones matter and turning them into issues, evaluators, examples and fixes. Engine's architecture follows that loop: it prepares context, screens traces at scale, investigates, creates the artifacts, hands fixes to another agent and updates its memory. According to LangChain, it has already changed how they improve their own agents: instead of digging through traces and writing evals separately, they turn production behavior into issues, fixes and tests. The article gives no metrics on how many failures it finds or how accurately; it's a description of the design.
Compress before you read, screen before you investigate, and let each agent do one thing.
Sources
- "How We Built LangSmith Engine, Our Agent for Improving Agents", by Palash Shah (LangChain), on X (May 19, 2026).
- My post on the LangSmith Engine announcement.
- The video, on my channels: English and Spanish.