What an AI agent harness does when the model stops
One of the harder problems in building a coding agent is knowing when to stop. In Anthropic's experiments with an agent building a web application across multiple sessions, some runs stalled because the agent took on too much at once and ran out of context.
A subtler failure came later. The agent would open a partially built application, see signs of progress, and conclude that the job was done. Anthropic's long-running agent experiments
That second failure is the one I find more interesting. A repository can contain a working interface and a tidy commit history while still missing features. When an agent says the work is complete, what evidence is it using? The answer depends partly on the software around the model: the agent harness.
What the harness does
An agent harness runs the loop that connects a model to its tools. The model might ask to inspect a file or run a test. The harness routes that request to the execution environment and returns the result so the model can decide what to do next.
Anthropic's Managed Agents architecture separates that loop from the environment in which commands run and the session log that records what happened. Anthropic's Managed Agents architecture
| Component | Role in a coding session |
|---|---|
| Model | Interprets the task and proposes the next action. |
| Harness | Supplies context, routes tool requests, and returns results. |
| Execution environment | Provides the working copy and runs commands. |
| Persistent state | Retains the events and artifacts a later session can use to resume work. |
I find this distinction useful when an agent gets stuck. If it chooses the wrong test, I'd look at the instructions and context it received. If it runs the right test but never sees the result, I'd trace the tool response. If the failure appears only after a restart, I'd check what survived and what the next session could recover.
A handoff the next session can use
Anthropic changed how it initialized the repository and how later sessions worked in it. The first session set up the environment, wrote a progress file, and made an initial Git commit. It also created a list of features with explicit acceptance criteria. Later sessions worked on individual features and left structured updates for the next session. Anthropic's experiment design
The feature list is the detail I'd borrow. A commit can tell me a login screen was added. I still need a check that someone can actually sign in.
Anthropic's team found that agents sometimes marked features complete without adequately testing them. The team's example included browser-level checks so the agent could verify behavior through the interface a user would see. Anthropic's testing observations
When the runtime goes down
Anthropic's Managed Agents write-up describes a related failure at the infrastructure level. The original design put the harness, execution environment, and session in one container. If that container failed, the session could be lost. The redesigned system keeps the event log outside the harness, allowing a replacement harness to load the recorded events and resume. An execution environment can also fail independently, in which case its failure can be returned as a tool error. Managed Agents recovery design
I'd keep two questions in mind here. What did the agent last ask a tool to do? And what state did that tool leave behind? The session log can help answer the first. For the second, the agent may need to inspect the repository or query the system the tool interacted with. That distinction matters when a tool finishes an operation just before the runner stops recording events.
How I'd test a harness
I'd start with the same model and task in two setups. In each run, I'd interrupt the session after a code change and before verification. Then I'd start a fresh session and check whether it can recover the unfinished requirement, find the relevant change, and run the check that would justify marking the feature complete. I'd track repeated work and look for any point where the agent claims success without evidence.
I'd also test what happens when a tool completes an operation and the runner stops before saving the result. Repeating a read-only lookup is usually straightforward. Repeating an operation that changes state may create a duplicate. I'd want the harness to check the target system for the prior outcome before trying the operation again.
The question I'd ask at the end of either test is simple: If another developer took over right now, could they tell what happened, what was verified, and what still needs work? A good handoff gives them enough evidence to continue without starting over.
Comments
No comments yet. Start the discussion.