Anthropic Effective Harnesses for Long-Running Agents
Anthropic has developed a specialized agent harness to solve the problem of "memory loss" and inconsistent progress when AI agents work across multiple discrete sessions. By splitting the workflow between an initializer agent and a coding agent, developers can enable models like Opus 4.5 to complete complex, production-quality projects that exceed the limits of a single context window.
The Challenge of Long-Running Agents
Standard agent harnesses often fail on complex, multi-session tasks because each new session begins without memory of previous actions. Anthropic identified two primary failure modes when using the Claude Agent SDK for long-horizon tasks:
- Over-ambition (One-shotting): Agents attempt to implement too many features at once, exhausting the context window and leaving the project in a half-implemented, undocumented state.
- Premature Completion: Later agent instances may see existing progress and incorrectly declare the entire project finished before all requirements are met.
While context compaction helps, it is often insufficient to provide the clear, structured instructions necessary for a subsequent agent to resume work without guessing or wasting tokens on recovery.
The Two-Agent Solution
To bridge the gap between sessions, Anthropic employs a two-part prompting strategy. Although the underlying system prompt and tools remain identical, the initial user prompts differ to create two distinct roles:
1. The Initializer Agent
The initializer agent is used only for the first session. Its primary goal is to establish a foundation that guides all future agents. Key outputs include:
- Feature List: A comprehensive JSON file expanding the user's high-level prompt into detailed requirements (e.g., over 200 features for a claude.ai clone). Each feature is initially marked as
"passes": false. - Environment Setup: An
init.shscript to automate starting the development server and basic end-to-end tests. - Tracking Infrastructure: A
claude-progress.txtfile for logging progress and an initial git commit to establish the codebase state.
2. The Coding Agent
Subsequent sessions use the coding agent, which is tasked with making incremental progress. To prevent the failure modes mentioned above, the coding agent follows a strict operational loop:
- Orientation: Every session begins by running
pwd, readingclaude-progress.txt, reviewing the git log, and reading thefeature_list.jsonfile. - Incremental Implementation: The agent works on only one feature at a time, preventing context exhaustion.
- Verification: The agent must use browser automation tools (such as the Puppeteer MCP server) to verify features end-to-end as a human user would, rather than relying solely on unit tests or code inspection.
- Clean Handoff: Before ending a session, the agent must commit its progress to git with descriptive messages and update the progress file, ensuring the environment is in a "merge-ready" state for the next agent.
Summary of Failure Modes and Mitigations
| Problem | Initializer Agent Action | Coding Agent Action |
|---|---|---|
| Premature project victory | Create structured JSON feature list | Read feature list; work on one feature at a time |
| Buggy/undocumented state | Establish git repo and progress file | Read logs/progress; run basic tests at start; commit/update at end |
| Premature feature completion | Create feature list | Self-verify via end-to-end testing before marking "passing" |
| Setup friction | Write init.sh script |
Run init.sh to start servers and verify state |
Technical Limitations and Future Directions
Despite the improvements, Anthropic noted specific limitations in current browser automation. For example, Claude cannot see browser-native alert modals through the Puppeteer MCP, which can lead to bugs in features relying on those modals.
Future research will explore whether a multi-agent architecture—utilizing specialized agents for testing, QA, and code cleanup—outperforms a single general-purpose coding agent. Additionally, Anthropic aims to generalize these harness patterns beyond web development into fields like financial modeling and scientific research.
Sources
Related
- Dispatch
- Dispatch
- Dispatch
- Dispatch
- Dispatch