LongHorizon-Harness keeps AI agents from drifting on long tasks
LongHorizon-Harness introduces a Manage-Execute-Audit loop to prevent agent compounding errors on marathon tasks. Fresh executors handle single subtasks in clean contexts while an independent auditor verifies actual environment changes before logging progress. Swapping in the harness boosted Qwen 3.7-Plus pass rates on WeaveBench from 51.8% to 80.7%.

LongHorizon-Harness is an open-source framework designed to solve one of the most frustrating bottlenecks in AI engineering: agents drifting off course during long-horizon tasks. Rather than training a new model, it acts as a structured harness around existing agents, keeping them anchored when tackling jobs that take hours or days to finish.
Most modern agent setups dump an entire multi-step project into a single, ever-expanding context window. As the transcript grows, the model struggles to retrieve what matters and starts compounding mistakes. An early hallucination poisons every subsequent choice, and because the agent grades its own homework, it often reports tasks as complete when they are broken, or loops for hundreds of steps trying the same broken action.
Decoupling execution from verification
LongHorizon-Harness replaces the monolithic session with what it calls the MEA loop: Manage, Execute, and Audit. The core insight is that task state must live outside the execution context and be updated exclusively through verified facts.
The Manager handles dynamic decomposition. Each round, it inspects the verified state record, checks what constraints remain active, and carves out a single bounded subtask with clear acceptance criteria. Across benchmarks, the Manager accounts for just 2% to 8% of total token spend.
The Executor operates inside a fresh, clean context for every subtask. It receives only what is needed for the current objective, performs the environment actions, and submits a report. Once finished, its raw execution history is thrown away entirely, preventing messy step-by-step logs from polluting long-term coordination.
The Auditor is a read-only role that acts as a strict gatekeeper. It inspects the real environment using read-only tools to verify whether files, diffs, or interface states actually match the contract. The Executor's self-assessment can guide where the Auditor looks, but cannot establish completion. Auditing takes 19% to 38% of total tokens, ensuring zero unverified claims enter the permanent record.
The framework enforces strict operational budgets: up to 1800 seconds per round for the Executor, 300 seconds each for the Manager and Auditor, capped at 25 MEA rounds per task.
Huge benchmark gains without touching the weights
Keeping the underlying foundation model and execution backend identical, swapping in LongHorizon-Harness consistently lifted performance across every benchmark tested.
On WeaveBench, which tests complex cross-interface workflows, pairing Qwen 3.7-Plus with the harness pushed pass rates from 51.8% to 80.7%, while the overall score rose from 0.702 to 0.835. On OSWorld 2.0, binary task completion tripled for Qwen 3.7-Plus from 2.8% to 8.3%, and rose from 20.6% to 35.3% for Claude Opus 4.7. On Terminal-Bench 2.1, success rates climbed from 69.7% to 77.2%.
Token consumption shows a practical trade-off. While auditing adds token overhead on complex GUI benchmarks like WeaveBench and OSWorld, the harness actually reduced total token consumption by 24% on Terminal-Bench 2.1 by eliminating repetitive death loops. On gaming tasks, Claude Opus 4.7 used 33% fewer tokens because stronger reasoning resolved contracts in fewer audit-replan cycles, whereas Qwen 3.7-Plus required 3.2 times more tokens to pass audit.
How to install and run
Getting started requires Python 3.10 or higher and an existing agent runtime accessible in your environment path.
Through a lightweight AgentAdapter, LongHorizon-Harness supports major agent runtimes out of the box, including Claude Code, Codex CLI, OpenClaw, and Hermes Agent, spanning backbone models like Claude Opus, GPT, and Qwen.
You can install the CLI tool directly using uv tool install lh-harness.
Running a task is straightforward from the terminal. You pass the target prompt, specify the agent backend and model, and set maximum rounds. Adding the --dashboard flag lets you observe the live MEA state machine in real time, with every run and audit trail cleanly isolated under a dedicated runs directory.
Why it matters
We think LongHorizon-Harness takes the right architectural bet: fixing long-context drift is not about expanding context windows, but about enforcing separation of duties. Treating progress verification as an independent, mandatory audit rather than an optional self-reflection stops hallucinations before they compound.
For developers building autonomous software engineers or multi-hour system administration bots, this is worth testing immediately. While you should expect higher token costs on messy tasks with weaker models, the trade-off pays off in sheer reliability.
Sources (1)
- lh-harness.pages.dev(opens in a new tab)Originallh-harness.pages.dev