Agent Handoff Receipts: A Contract for Agent-to-Agent Work Transfer

AI agents are starting to pass work to each other. One agent writes code, another reviews it, a third deploys it. But when work moves from agent to agent, the receiver has no way to know what it is receiving, who produced it, or whether it can refuse the handoff.

This post is a practical pattern for solving that: agent handoff receipts. Every handoff carries five fields the receiver checks before accepting. I also include a minimal Node.js reference implementation and a pre-flight gate script you can run today.

The Problem

Agent A builds something. Agent B is supposed to test or deploy it. Today, that handoff usually happens through a shared folder, a git branch, or a chat message. The receiver opens the artifact and has to guess:

  • What was this built to do?
  • Which model produced it, and with what prompt?
  • Can I reject it if it looks wrong?
  • Who do I ask if something breaks?

Without answers, the receiver either blindly accepts (and propagates errors) or stalls waiting for a human to clarify. Either way, work slows down and bugs leak through.

The Solution: Five Required Fields

A handoff receipt is a small JSON object attached to every agent-to-agent transfer. It contains exactly five fields:

Field Purpose Example
from The agent that produced the work (name + version) "codegen-agent.v1.2"
to The intended receiver agent "review-agent.v1.0"
task What the work is supposed to accomplish "Implement user export endpoint"
evidence Proof the work was checked (tests run, lint output, screenshots) {tests: "pass", lint: "clean"}
ttl Time-to-live — after this, the handoff expires and must be re-issued "24h"

The receiver validates each field before touching the artifact. If any field is missing or invalid, the handoff is refused. No exceptions.

Why Five Fields?

Each field answers a question the receiver cannot safely skip:

  • from — Who is responsible for this work? If something breaks, who do you contact?
  • to — Who is this handoff for? Prevents misrouted artifacts from being processed by the wrong agent.
  • task — What was this artifact supposed to accomplish? Lets the receiver verify the work matches the intent.
  • evidence — What checks have already run? Tests, lint, type checks, screenshots. The receiver can trust but verify instead of repeating everything.
  • ttl — When does this handoff expire? Stale work should not be deployed without re-review.

Missing any one of these weakens the chain. A handoff without from is anonymous. Without evidence, the receiver re-runs everything. Without ttl, an old fix could ship without anyone noticing it was never re-validated.

Reference Implementation

Here is a minimal Node.js implementation. The sender creates a receipt:

const crypto = require("node:crypto"); function createReceipt(from, to, task, evidence) { return { from, to, task, evidence, issuedAt: new Date().toISOString(), ttl: "24h", hash: crypto.createHash("sha256").update(JSON.stringify(evidence)).digest("hex"), }; } const receipt = createReceipt( "codegen-agent.v1.2", "review-agent.v1.0", "Implement user export endpoint", { tests: "pass", lint: "clean", files: ["src/export.js"] } ); console.log(JSON.stringify(receipt, null, 2)); 

Output:

{ "from": "codegen-agent.v1.2", "to": "review-agent.v1.0", "task": "Implement user export endpoint", "evidence": { "tests": "pass", "lint": "clean", "files": ["src/export.js"] }, "issuedAt": "2026-12-04T04:40:00.000Z", "ttl": "24h", "hash": "a1b2c3d4..." } 

The hash lets the receiver confirm the evidence has not been tampered with after the sender produced it.

The receiver validates it:

function parseTTL(ttl) { const match = /^(\d+)([hdm])$/.exec(ttl); if (!match) throw new Error(`Invalid TTL: ${ttl}`); const n = parseInt(match[1], 10); const unit = match[2]; const multipliers = { h: 3600000, d: 86400000, m: 60000 }; return n * multipliers[unit]; } function validateReceipt(receipt, now = new Date()) { const required = ["from", "to", "task", "evidence", "ttl"]; for (const field of required) { if (!(field in receipt)) { throw new Error(`Missing receipt field: ${field}`); } } const ttlMs = parseTTL(receipt.ttl); const age = now - new Date(receipt.issuedAt); if (age > ttlMs) { throw new Error("Receipt expired"); } return true; } 

Pre-Flight Gate

Before any agent commits work produced by another agent, run a gate. The gate checks:

  1. Receipt exists and validates
  2. Evidence shows tests passed
  3. TTL has not expired
  4. The from agent is on the allowlist

If the gate fails, the commit is blocked. This prevents unverified handoffs from reaching production.

Here is a minimal gate script:

const fs = require("node:fs"); function runGate(receiptPath) { const receipt = JSON.parse(fs.readFileSync(receiptPath, "utf8")); validateReceipt(receipt); if (!receipt.evidence || receipt.evidence.tests !== "pass") { throw new Error("Tests not passed in receipt evidence"); } const allowed = ["codegen-agent.v1.2", "review-agent.v1.0", "deploy-agent.v1.0"]; if (!allowed.includes(receipt.from)) { throw new Error(`Untrusted sender: ${receipt.from}`); } console.log("Gate: PASS"); return true; } try { runGate(process.argv[2]); process.exit(0); } catch (e) { console.error(`Gate: FAIL - ${e.message}`); process.exit(1); } 

Run it in your CI:

node gate.js receipt.json 

When to Refuse a Handoff

A receiver should refuse when:

  • The receipt is missing or malformed
  • The evidence does not cover the actual work (for example, tests ran on a different file than the one being deployed)
  • The TTL has expired (the work may be stale)
  • The from agent is not on the allowlist
  • The hash in the receipt does not match the actual artifact contents

Refusing a handoff is not a failure — it is the system working as designed. The sender should fix the issue and re-issue the handoff with a fresh receipt.

Real-World Example

Here is what a complete handoff looks like in practice:

  1. The codegen agent finishes the user export endpoint and writes receipt.json alongside the changed files.
  2. The review agent picks up the branch, reads receipt.json, and runs validateReceipt. Validation passes.
  3. The review agent runs its own checks, updates evidence.tests to "pass", and creates its own receipt addressed to the deploy agent.
  4. The deploy agent receives the reviewed artifact, validates the review agent's receipt, and deploys.
  5. If any step fails, the chain stops. No unvetted code reaches production.

What the Receipt Does Not Do

The receipt is not a replacement for code review. It does not verify that the code is correct, secure, or well-designed. What it does is make the handoff explicit: the receiver knows who sent it, what it is supposed to do, what checks already ran, and when it expires. Everything else — design, security, correctness — still needs human or agent review.

It is also not an identity system. The from field tells you which agent sent the handoff, but it does not prove that agent is who it claims to be. For strong identity, combine receipts with mTLS, signed JWTs, or another transport-layer mechanism. The receipt is an application-layer contract; trust in the sender is a separate concern.

Operational Checklist

Before adopting receipts in your team, answer these questions:

  1. Which agents produce and receive handoffs? List them explicitly.
  2. Where do receipts live? Alongside the artifact, in a separate metadata file, or in a database?
  3. Who maintains the allowlist of trusted senders? How is it updated?
  4. What TTL makes sense for your workflow? A few hours for CI pipelines, longer for manual review queues.
  5. What happens when a receipt expires mid-flight? The receiver should reject and request a re-issue.

Common Anti-Patterns

Avoid these mistakes when introducing receipts:

  • Skipping validation when the sender is "trusted." Trust is not a substitute for a valid receipt. A trusted agent can still send malformed or expired work.
  • Reusing the same receipt across multiple artifacts. Each handoff needs its own receipt. Reusing one across files breaks the hash check and hides which artifact was actually verified.
  • Setting TTL too long. A week-long TTL means stale work can ship without re-review. Match TTL to your review cadence.
  • Putting business logic in the evidence field. Evidence should list checks that ran (tests, lint, screenshots), not describe what the code does. The task field covers intent.

Summary

Agent-to-agent work transfer needs a contract, not a chat message. Five fields in a receipt give the receiver enough information to accept or refuse, with evidence attached. The reference implementation is under 60 lines of Node.js, and the pre-flight gate blocks bad handoffs before they reach production.

Start small: add a receipt.json to your next agent-produced artifact, and have the receiving agent validate it before touching the code. That single step prevents more production incidents than most complex review processes. The goal is not to slow agents down — it is to let them move fast without breaking things they cannot see. One receipt, one gate, one fewer silent failure in production. The pattern scales from a two-agent pipeline to a multi-agent fleet without adding central coordination.

This post was written with AI assistance. The author is responsible for its content.