Improving Deep Agents with Harness Engineering — LangChain logo

Improving Deep Agents with Harness Engineering — LangChain

Free

TerminalBench 2.0 case study: 52.8% → 66.5%, same model

FreeFree tier
Type
Open Source
Founded
2023
Company
LangChain

About Improving Deep Agents with Harness Engineering — LangChain

This blog post from LangChain details a case study on improving agent performance through harness engineering. The authors describe how they improved their coding agent (deepagents-cli) from 52.8% to 66.5% on the TerminalBench 2.0 benchmark (moving from Top 30 to Top 5) by only modifying the agent's harness—system prompt, tools, and middleware—while keeping the underlying model (GPT-5.2-Codex) fixed. The post introduces a repeatable trace analysis skill that uses LangSmith to automatically analyze failure modes across experiment runs, and highlights the importance of self-verification loops where agents test and correct their own outputs. It also discusses trade-offs such as overfitting and the need for generalization.

Key Features

Self-verification loops for automatic testing and improvement within runs
Trace analysis skill that fetches LangSmith traces, analyzes errors, and suggests harness changes
Focus on three harness knobs: system prompt, tools, and middleware
Automated, repeatable failure analysis to accelerate improvement cycles
Designed for coding agents but methodology applies to other agent tasks

Pros & Cons

Pros
  • Self-verification significantly boosts agent performance without model changes
  • Trace analysis skill saves hours of manual debugging
  • Methodology is repeatable and can be generalized to other agent tasks
  • Uses real-world observability data (LangSmith) to drive improvements
Cons
  • Changes that overfit to specific tasks can cause regressions on other tasks
  • Requires careful generalization and human validation in the feedback loop
  • Models remain black-box, limiting interpretability of internal reasoning
  • Benchmarks like TerminalBench 2.0 may not capture all real-world scenarios

Best For

Improving coding agent performance on benchmarks like TerminalBench 2.0Systematic debugging and enhancement of agent harnessesAutomated trace analysis to identify failure patterns in agent runsBuilding self-verifying agents that test and refine their own outputs

FAQ

What is harness engineering?
Harness engineering is the practice of building tooling around a model—such as system prompts, tools, and execution flow—to optimize goals like task performance, token efficiency, and latency. It molds the model's intelligence for specific tasks.
How did self-verification improve the agent?
Self-verification lets agents automatically test and refine their outputs within a single run. This turned the most common failure pattern (writing code, re-reading it, and stopping without testing) into a build-verify loop that significantly boosted correctness.
What was the main outcome of the experiment?
By only tweaking the harness (system prompt, tools, and middleware) and keeping the same model (GPT-5.2-Codex), the agent's score on TerminalBench 2.0 rose from 52.8% to 66.5%, moving it from outside the Top 30 to the Top 5.
What tools were used in the experiment?
The experiment used TerminalBench 2.0 for evaluation, Harbor for orchestration, Daytona for sandboxes, LangSmith for storing traces and metrics, and a custom trace analysis skill for automated error analysis.