Effective Harnesses for Long-Running Agents — Anthropic
FreeLong-running agent design
FreeFree tier
About Effective Harnesses for Long-Running Agents — Anthropic
An open-source reference implementation for building long-running agents using the Claude Agent SDK. The harness addresses the challenge of agents working across multiple context windows by using a two-agent architecture: an initializer agent that sets up the environment and a coding agent that makes incremental progress while leaving clean artifacts. This approach prevents common failure modes like context exhaustion and premature task completion. Includes a quickstart with code examples for setting up the agent loop, init scripts, and progress tracking.
Key Features
Two-agent architecture: initializer and coding agent
Initializer agent sets up environment and task structure
Coding agent makes incremental progress per session
Leaves environment in a clean, documented state
Context window management across sessions
Uses init.sh, claude-progress.txt, and git commits for state tracking
Pros & Cons
Pros
- Enables agents to make consistent progress across many context windows
- Prevents agents from attempting to one-shot the entire task
- Avoids premature completion by ensuring incremental progress
- Leaves code in a clean, merge-ready state after each session
- Provides clear structure via init scripts and progress logs
Cons
- Requires careful initial setup with specialized prompts
- May need tuning for different types of projects
- Complexity of orchestrating two agents adds overhead
Best For
Building complex web applications over multiple coding sessionsLong-running software projects requiring days of agent workAutomated feature development with consistent progress trackingMulti-session coding tasks where context cannot be retained
FAQ
What problem does this harness solve?
It addresses the challenge of AI agents working across multiple context windows, where each new session has no memory of previous work. The harness prevents common failure modes like attempting to do too much at once or prematurely declaring a task complete.
How does the initializer agent work?
The initializer agent is prompted to set up the initial environment on the first run, creating an init.sh script, a claude-progress.txt log file, and an initial git commit to establish a foundation for subsequent sessions.
What does the coding agent do?
The coding agent is tasked with making incremental progress in each session while leaving the environment in a clean state, with orderly and well-documented code that a developer can easily continue from.