All posts

AI Engineering

The Artifact Is Correct, but the Next Agent Is Stuck: Testing Handoff Completion

A practical multi-agent completion contract inspired by CLASHarness: verify the artifact, lock release and acknowledgment of the current version with a runnable example and failure-path tests.

Published and maintained by Sambro · Report a correction

7 min read Multi-agent systemsAgent harnessCLASHarnessHandoff verification

A correct file can leave a workflow unfinished

A drafting agent produces the right file and reports that the job is done. The reviewer still cannot proceed because the drafting lock remains held. In another run, a review acknowledgment exists, but it refers to the version before the last edit. A test that checks only the file contents misses both problems.

We will separate completion into four observable conditions: the artifact meets its requirement, the producer stage succeeded, this task’s lock is released, and the intended next worker has acknowledged the current version. This is a way to make a chosen workflow contract explicit, not a requirement that every collaboration use the same protocol.

The question prompted by CLASHarness

Yuxiang Lai and eight coauthors submitted CLASHarness on October 13, 2026 at 20:01 UTC, October 14 in Korea. It evaluates conflict-loaded computer-use tasks, including contradictory peer reports and unfinished lock releases or handoffs. Paper and authors: CLASHarness — arXiv abstract

The authors report a gap between detecting conflict and repairing state. Their limitations include asynchronous traces, LLM semantic judging and no conflict-free baseline. Our example below is an original Sambro teaching fixture, not a reproduction of CLASHarness or any model’s performance. Full paper: CLASHarness — paper, version 1

Completion includes the version that was handed over

A single sent-to-review flag loses important information. Delivery and acknowledgment can differ, and an artifact may change afterward. Our fixture binds task identity, the expected recipient, a revision number and a SHA-256 content hash to the acknowledgment. A new revision requires a new acknowledgment even when its content is unchanged.

A hash does not establish correctness or authenticate a recipient. Here it only identifies which content was acknowledged. A separate check decides whether that content is correct. A production service also needs task identity, authorization, acceptance criteria and a retry policy.

An absent lock is not enough either. A producer exception leaves its stage failed. When production succeeds but acknowledgment is missing or rejected, producer status can be completed while the end-to-end result remains complete=false. Successful cleanup does not stand in for a receipt.

Run a small handoff experiment

The example runs on Node.js 22 or later without packages, API keys or model downloads. Save both files in the same folder. Example: agent handoff — demo.mjs

Tests: agent handoff — demo.test.mjs

The deliberately unfinished case passes the artifact-only check. The full completion check rejects its retained lock and missing handoff. The successful path passes only after producing the artifact, receiving acknowledgment and releasing its owned lock. The output shown here comes from running our fixture, not from a simulated model transcript.

We verified the output below and eight passing tests on Node.js v24.19.0.

Run the fixture and regression tests
node demo.mjs
node --test demo.test.mjs
Observed fixture output
output-only {"complete":false,"checks":{"artifactCorrect":true,"statusCompleted":false,"lockReleased":false,"handoffAcknowledged":false}}
awaiting-receipt {"complete":false,"checks":{"artifactCorrect":true,"statusCompleted":true,"lockReleased":true,"handoffAcknowledged":false}}
acknowledged {"complete":true,"checks":{"artifactCorrect":true,"statusCompleted":true,"lockReleased":true,"handoffAcknowledged":true}}
exception {"status":"failed","lockOwner":null,"complete":false,"error":"Producer crashed"}
foreign-lock {"error":"Lock held by other-worker","lockOwner":"other-worker","releasedByWriter":false}
stale-receipt {"error":"Stale or mismatched handoff","oldRevision":1,"currentRevision":2,"sameHash":true,"complete":false}

Failure must clean up without claiming success

The regression tests distinguish producer exceptions, incorrect artifacts and rejected acknowledgments. Production failure is recorded as failure while releasing the lock it owns, never another worker’s lock. Even after an artifact exists, a wrong recipient or stale receipt cannot establish end-to-end success.

An acknowledgment from the wrong recipient, or one whose hash does not match the current artifact, must fail the completion contract. A more confident completion message cannot repair these state mismatches.

This is a sequential, single-process, in-memory experiment. It does not implement distributed locking, transactions or recovery from process termination. Concurrent production workers need atomic ownership checks, expiration and recovery policies, and protection against stale writers. A finally block is not guaranteed to run when a process is forcibly terminated.

Even an official smoke test needs more than an exit code

The CLASHarness Quick Start, checked on October 21, 2026, distinguishes its mock pipeline from model evaluation. It documents a run in which six of twenty seeds materialize and fourteen fail while the process still exits zero. These are documented results, not measurements we made. Guide: CLASHarness — Quick Start

Treat process termination and expected-result validation as separate signals. If you try the official pipeline, read the materialized count and judge-health output as well. We did not run that pipeline or call a paid model for this article. Source: CLASHarness — source repository

Where to apply this in your own agent

Choose one frequently delegated task with a clear boundary, such as producing a reviewable file and handing it to the next worker. Specify the artifact criterion, lock owner, intended recipient and acknowledged version. Apply the same completion checks to successful, failed and interrupted runs. Requiring acknowledgment everywhere can add waiting, so start where the handoff actually matters.

Our earlier replay guide focuses on observing a failure again with fixed inputs and tool results. This article focuses on when a shared-state handoff is finished. The checks can work together. Related guide: Give Coding Agents the Same Bug Twice: A JSON Replay Walkthrough

In production, observe handoff latency, remaining locks, rejected stale acknowledgments and recovery events alongside end-to-end completion rate. Passing this teaching fixture does not guarantee reliable collaboration or lower operating costs.

Back to Sambro Blog