@xiaomovps: 研究了这么多 AI Agent,我越来越觉得,Harness 才是最值得深入研究的方向 最近看到 Anthropic 分享的一篇关于长任务 Agent 的文章,里面的一些思路让我挺有感触的 因为我自己不管是研究和使用都折腾过不少Harne…

X AI KOLs Timeline 新闻

摘要

博主结合自身研究 Pi Agent、DeepSeek Harness、Claude Code 等经验,总结 Harness 是 Agent 最值得深挖的方向,并分享 Anthropic 关于长任务 Agent 的文章,提出上下文管理、长任务执行与结果验证三大关键问题。

研究了这么多 AI Agent,我越来越觉得,Harness 才是最值得深入研究的方向 最近看到 Anthropic 分享的一篇关于长任务 Agent 的文章,里面的一些思路让我挺有感触的 因为我自己不管是研究和使用都折腾过不少Harness,包括 Pi Agent、DeepSeek Harness、Claude Code、Codex,还有 Hermes Agent 在这个过程中发现每一个Harness其实本质都很像,但是表现出来的结果却各不相同,有可能同一个模型在不同的Harness上表现就不一样 我总结下来,一般在这几个问题上 1、首先是上下文管理 因为 Agent 在执行复杂任务的时候,会不断积累上下文,如何保留重要信息、压缩无用内容,以及在上下文切换之后继续理解之前的任务,其实很考验 Harness 的设计 2、其次是长任务的执行能力 这方面我自己踩过不少坑,有时候一个任务运行几十分钟突然卡死,或者中途出现问题只能重新开始 所以我觉得一个成熟的 Harness,不应该只是能够执行任务,还需要考虑任务状态、异常恢复,以及怎么从中断的位置继续执行 3、最后是结果验证 这也是我觉得很容易被忽略的地方,很多时候 Agent 告诉你任务已经完成了,但实际结果可能并不符合预期 如果缺少可靠的验证机制,模型再强,也很难保证复杂任务的最终质量 我希望市面上的Harness越来越好,尤其是国产的Harness 不管是DeepSeek Harness还是WorkBuddy,只有强力模型搭配强力Harness才是唯一出入 如果你也在研究这个方向,推荐看看: https://anthropic.com/engineering/effective-harnesses-for-long-running-agents…
查看原文
查看缓存全文

缓存时间: 2026/11/21 08:19

研究了这么多 AI Agent,我越来越觉得,Harness 才是最值得深入研究的方向

最近看到 Anthropic 分享的一篇关于长任务 Agent 的文章,里面的一些思路让我挺有感触的

因为我自己不管是研究和使用都折腾过不少Harness,包括 Pi Agent、DeepSeek Harness、Claude Code、Codex,还有 Hermes Agent

在这个过程中发现每一个Harness其实本质都很像,但是表现出来的结果却各不相同,有可能同一个模型在不同的Harness上表现就不一样

我总结下来,一般在这几个问题上

1、首先是上下文管理

因为 Agent 在执行复杂任务的时候,会不断积累上下文,如何保留重要信息、压缩无用内容,以及在上下文切换之后继续理解之前的任务,其实很考验 Harness 的设计

2、其次是长任务的执行能力

这方面我自己踩过不少坑,有时候一个任务运行几十分钟突然卡死,或者中途出现问题只能重新开始

所以我觉得一个成熟的 Harness,不应该只是能够执行任务,还需要考虑任务状态、异常恢复,以及怎么从中断的位置继续执行

3、最后是结果验证

这也是我觉得很容易被忽略的地方,很多时候 Agent 告诉你任务已经完成了,但实际结果可能并不符合预期

如果缺少可靠的验证机制,模型再强,也很难保证复杂任务的最终质量

我希望市面上的Harness越来越好,尤其是国产的Harness 不管是DeepSeek Harness还是WorkBuddy,只有强力模型搭配强力Harness才是唯一出入

如果你也在研究这个方向,推荐看看:

https://anthropic.com/engineering/effective-harnesses-for-long-running-agents…


Effective harnesses for long-running agents

Source: https://www.anthropic.com/research/effective-harnesses-for-long-running-agents As AI agents become more capable, developers are increasingly asking them to take on complex tasks requiring work that spans hours, or even days. However, getting agents to make consistent progress across multiple context windows remains an open problem.

The core challenge of long-running agents is that they must work in discrete sessions, and each new session begins with no memory of what came before. Imagine a software project staffed by engineers working in shifts, where each new engineer arrives with no memory of what happened on the previous shift. Because context windows are limited, and because most complex projects cannot be completed within a single window, agents need a way to bridge the gap between coding sessions.

We developed a two-fold solution to enable theClaude Agent SDKto work effectively across many context windows: aninitializer agentthat sets up the environment on the first run, and acoding agentthat is tasked with making incremental progress in every session, while leaving clear artifacts for the next session. You can find code examples in the accompanyingquickstart.

The long-running agent problem

The Claude Agent SDK is a powerful, general-purpose agent harness adept at coding, as well as other tasks that require the model to use tools to gather context, plan, and execute. It has context management capabilities such as compaction, which enables an agent to work on a task without exhausting the context window. Theoretically, given this setup, it should be possible for an agent to continue to do useful work for an arbitrarily long time.

However, compaction isn’t sufficient. Out of the box, even a frontier coding model like Opus 4.5 running on the Claude Agent SDK in a loop across multiple context windows will fall short of building a production-quality web app if it’s only given a high-level prompt, such as “build a clone ofclaude.ai.”

Claude’s failures manifested in two patterns. First, the agent tended to try to do too much at once—essentially to attempt to one-shot the app. Often, this led to the model running out of context in the middle of its implementation, leaving the next session to start with a feature half-implemented and undocumented. The agent would then have to guess at what had happened, and spend substantial time trying to get the basic app working again. This happens even with compaction, which doesn’t always pass perfectly clear instructions to the next agent.

A second failure mode would often occur later in a project. After some features had already been built, a later agent instance would look around, see that progress had been made, and declare the job done.

This decomposes the problem into two parts. First, we need to set up an initial environment that lays the foundation forallthe features that a given prompt requires, which sets up the agent to work step-by-step and feature-by-feature. Second, we should prompt each agent to make incremental progress towards its goal while also leaving the environment in a clean state at the end of a session. By “clean state” we mean the kind of code that would be appropriate for merging to a main branch: there are no major bugs, the code is orderly and well-documented, and in general, a developer could easily begin work on a new feature without first having to clean up an unrelated mess.

When experimenting internally, we addressed these problems using a two-part solution:

  1. Initializer agent: The very first agent session uses a specialized prompt that asks the model to set up the initial environment: aninit\.shscript, a claude-progress.txt file that keeps a log of what agents have done, and an initial git commit that shows what files were added.
  2. Coding agent: Every subsequent session asks the model to make incremental progress, then leave structured updates.1

The key insight here was finding a way for agents to quickly understand the state of work when starting with a fresh context window, which is accomplished with the claude-progress.txt file alongside the git history. Inspiration for these practices came from knowing what effective software engineers do every day.

Environment management

In the updatedClaude 4 prompting guide, we shared some best practices for multi-context window workflows, including a harness structure that uses “a different prompt for the very first context window.” This “different prompt” requests that the initializer agent set up the environment with all the necessary context that future coding agents will need to work effectively. Here, we provide a deeper dive on some of the key components of such an environment.

Feature list

To address the problem of the agent one-shotting an app or prematurely considering the project complete, we prompted the initializer agent to write a comprehensive file of feature requirements expanding on the user’s initial prompt. In theclaude.aiclone example, this meant over 200 features, such as “a user can open a new chat, type in a query, press enter, and see an AI response.” These features were all initially marked as “failing” so that later coding agents would have a clear outline of what full functionality looked like.

We prompt coding agents to edit this file only by changing the status of a passes field, and we use strongly-worded instructions like “It is unacceptable to remove or edit tests because this could lead to missing or buggy functionality.” After some experimentation, we landed on using JSON for this, as the model is less likely to inappropriately change or overwrite JSON files compared to Markdown files.

Incremental progress

Given this initial environment scaffolding, the next iteration of the coding agent was then asked to work on only one feature at a time. This incremental approach turned out to be critical to addressing the agent’s tendency to do too much at once.

Once working incrementally, it’s still essential that the model leaves the environment in a clean state after making a code change. In our experiments, we found that the best way to elicit this behavior was to ask the model to commit its progress to git with descriptive commit messages and to write summaries of its progress in a progress file. This allowed the model to use git to revert bad code changes and recover working states of the code base.

These approaches also increased efficiency, as they eliminated the need for an agent to have to guess at what had happened and spend its time trying to get the basic app working again.

Testing

One final major failure mode that we observed was Claude’s tendency to mark a feature as complete without proper testing. Absent explicit prompting, Claude tended to make code changes, and even do testing with unit tests orcurlcommands against a development server, but would fail recognize that the feature didn’t work end-to-end.

In the case of building a web app, Claude mostly did well at verifying features end-to-end once explicitly prompted to use browser automation tools and do all testing as a human user would.

Providing Claude with these kinds of testing tools dramatically improved performance, as the agent was able to identify and fix bugs that weren’t obvious from the code alone.

Some issues remain, like limitations to Claude’s vision and to browser automation tools making it difficult to identify every kind of bug. For example, Claude can’t see browser-native alert modals through the Puppeteer MCP, and features relying on these modals tended to be buggier as a result.

Getting up to speed

With all of the above in place, every coding agent is prompted to run through a series of steps to get its bearings, some quite basic but still helpful:

  1. Runpwdto see the directory you’re working in. You’ll only be able to edit files in this directory.
  2. Read the git logs and progress files to get up to speed on what was recently worked on.
  3. Read the features list file and choose the highest-priority feature that’s not yet done to work on.

This approach saves Claude some tokens in every session since it doesn’t have to figure out how to test the code. It also helps to ask the initializer agent to write an init.sh script that can run the development server, and then run through a basic end-to-end test before implementing a new feature.

In the case of the claude.ai clone, this meant that the agent always started the local development server and used the Puppeteer MCP to start a new chat, send a message, and receive a response. This ensured that Claude could quickly identify if the app had been left in a broken state, and immediately fix any existing bugs. If the agent had instead started implementing a new feature, it would likely make the problem worse.

Given all this, a typical session starts off with the following assistant messages:

Future work

This research demonstrates one possible set of solutions in a long-running agent harness to enable the model to make incremental progress across many context windows. However, there remain open questions.

Most notably, it’s still unclear whether a single, general-purpose coding agent performs best across contexts, or if better performance can be achieved through a multi-agent architecture. It seems reasonable that specialized agents like a testing agent, a quality assurance agent, or a code cleanup agent, could do an even better job at sub-tasks across the software development lifecycle.

Additionally, this demo is optimized for full-stack web app development. A future direction is to generalize these findings to other fields. It’s likely that some or all of these lessons can be applied to the types of long-running agentic tasks required in, for example, scientific research or financial modeling.

相似文章

@Potatoloogs: https://x.com/Potatoloogs/status/2057391224592667051

X AI KOLs Timeline

本文深度拆解了Agent Harness的概念,即包裹在LLM外部的工程基础设施,包括编排循环、工具调用、记忆系统、上下文管理等12个组件。文章引用Anthropic、OpenAI、LangChain等公司的实践,论证了harness对生产级AI Agent的关键作用。

@xiaogaifun: 讲 Harness 最透彻的一个演讲。 这应该是我看到过的、关于 Harness Engineering 最透彻的一次分享,推荐大家看一下。 视频链接:https://podwise.ai/dashboard/episodes/80132…

X AI KOLs Timeline

这篇文章通过IBM工程师Tejas Kumar的演讲,深入讲解了Harness Engineering的概念,即通过为AI Agent添加确定性基础设施(如工具注册表、上下文管理、护栏和验证循环)来解决模型失控和幻觉问题,确保Agent稳定执行任务。