techlist.io
Anthropic2025-11-264 min read

Curated summary

Effective harnesses for long-running agents

Read original(opens in new tab)

Anthropic's Approach to Long-Running Agents Across Context Windows

Long-running agents struggle because each new session starts with no memory of prior work, and compaction alone does not keep progress consistent across many context windows. Anthropic addresses this with a two-part harness: an initializer agent that sets up the environment on the first run, and a coding agent that makes incremental progress each session while leaving clean, documented artifacts for the next one. The approach was tested by building a claude.ai clone with the Claude Agent SDK, and it substantially reduced the failure modes that plague multi-session development.

Why Long-Running Agents Fail

  • Compaction preserves some context, but it does not reliably pass clear instructions to the next agent.
  • Agents tend to try to do too much at once, often running out of context mid-implementation and leaving a feature half-built and undocumented.
  • Later agents may look at partial progress and declare the whole project finished too early.
  • Without a clean handoff, each new session must spend time guessing what happened and getting the basic app working again.

The Two-Part Solution

  • Initializer agent: The first session uses a specialized prompt to create an init.sh script for starting the dev server, a claude-progress.txt log of agent activity, and an initial git commit showing the added files.
  • Coding agent: Every later session makes incremental progress on one feature, then leaves structured updates through git commits and progress notes.
  • The two agents differ only in their initial user prompt. The system prompt, tools, and harness are otherwise identical.

Environment Scaffolding

Feature List

  • The initializer expands the user's prompt into a comprehensive JSON feature list. The claude.ai clone example produced over 200 features, each with a category, description, verification steps, and a passes field.
  • All features start as failing, giving later agents a clear picture of full functionality.
  • Coding agents may only change the passes status. The prompt forbids removing or editing tests.
  • JSON was chosen over Markdown because the model is less likely to inappropriately overwrite it.

Incremental Progress and Git

  • Coding agents work on one feature at a time, which curbs the tendency to one-shot the app.
  • Agents commit to git with descriptive messages and update the progress file, so bad changes can be reverted and working states recovered.
  • This removes the need for each new session to reconstruct what happened.

Testing

  • Claude often marked features complete after unit tests or curl checks, without confirming they worked end-to-end.
  • Explicitly prompting it to use browser automation (Puppeteer MCP) and test as a human user would markedly improved results, exposing bugs not visible from the code alone.
  • Remaining limitations include weak vision and an inability to see browser-native alert modals, which made features relying on them buggier.

Getting Up to Speed

Each coding session starts with a consistent routine:

  • Run pwd to confirm the working directory.
  • Read the git log and progress file to see recent work.
  • Read the feature list and select the highest-priority unfinished feature.
  • Run init.sh to start the dev server and perform a basic end-to-end check, such as creating a chat and receiving a response. This catches any broken state left by the previous session before new work begins.

Failure Modes and Mitigations

  • Premature victory: The initializer writes a feature list; the coding agent works on one feature and verifies it.
  • Buggy or undocumented handoffs: The initializer creates a git repo and progress notes; the coding agent reads them first and ends each session with a commit and update.
  • Premature completion marks: Agents self-verify every feature before marking it passing.
  • Time spent figuring out how to run the app: The initializer writes init.sh, which the coding agent runs at the start of each session.

Open Questions and Future Work

  • It is unclear whether a single general-purpose coding agent performs best, or whether specialized agents for testing, QA, or code cleanup would do better.
  • The demo targets full-stack web development. Anthropic hopes to generalize these lessons to fields such as scientific research and financial modeling.

Continue with another curated summary.