Agents that work for other agents need a contract that isn't a web page — so we shipped a Commerce API where task, offer, agreement, submission, evidence and payment are all signed REST objects with an auditable event chain. No escrow, no checkout: trust is a Postgres-enforced hash chain. Then we pointed cloud Devin — an external AI agent with a fresh ephemeral wallet — at the live production API. It ran the full deal end to end, found two real bugs our 44 green tests missed, we fixed both, and it re-verified the fixes.
Agents that work for other agents need a contract that isn't a web page — so we shipped a Commerce API where a task, an offer, an agreement, the delivered work, its evidence and the payment record are all signed REST objects with an auditable event chain. No escrow, no checkout, no platform holding the money: trust is a hash chain anyone can recompute. An external AI agent (cloud Devin) ran the full deal on production, found two real bugs our 44 green tests missed, we fixed both, and it re-verified the fixes.
Why would an agent need a contract, not a checkout? #
A checkout page assumes a human who reads, clicks and disputes through support. Two agents closing a deal have none of that - they have wallets and they need the deal itself to be data: the task, the offer, who agreed to what, what was delivered, whether it was accepted, whether it was paid. If any of that lives in a chat log or a database row nobody can audit, the deal didn't happen - it was alleged.
So we built the model the spec asks for: Task → Offer → Agreement → Submission → Evidence → Payment - six signed REST objects under /api/commerce/*, fifteen endpoints, every mutation appended to a per-entity hash chain. Payment is RECORD_ONLY by design: the API records that a payment was made and verified, it does not move funds - settlement is a separate concern (D-224-4), which is why payment status and task status deliberately can't imply each other.
For a junior: think of a restaurant with an open kitchen. Nobody locks the ingredients in a vault (escrow) - instead, every step is filmed and the film is unforgeable. You don't need to trust the chef when you can replay the tape.
How does a deal flow through fifteen endpoints? #
The happy path, as run live on production by the external agent:
Eight signed requests, one deal. Every arrow appends an event to the hash chain.
- Task - buyer posts
{title, budget, currency, status: OPEN}. - Offer - provider quotes a price and proposal.
- Accept - buyer accepts exactly one offer. The accept is atomic: offer → agreement → task transition → payment record, all in one database transaction. Two concurrent accepts can't fork this - one gets 200, the other gets 409.
- Submission + Evidence - provider delivers
{summary, resultUrl}plus typed evidence (URL,HASHorTRANSACTION- a tx-hash reference, since settlement lives off the API). - Review - buyer accepts or requests revisions (
REVISION_REQUIREDre-opens the submission). Only the buyer reviews; a provider can't grade its own homework. - Payment record - buyer records
{paymentId, note}referencing the external transfer. - Verify - the payee, and only the payee, confirms. Buyer verify → 403.
Every write request is signed: an EIP-191 personal signature over a agentbadge-commerce:v2 challenge that binds the method, path, timestamp, a one-time nonce, the request body's SHA-256 and the idempotency key into the signed text. A tampered body invalidates the signature; a replayed nonce collides; a duplicate idempotency key returns the original response.
Payment status and task status are different roads. A completed task can still be unpaid - and the API refuses to pretend otherwise.
What did the external agent break? #
Before the Devin run, an Arc Studio adversarial review had already found 2 Critical + 6 High issues - non-atomic accepts, replay gaps, review authorization, DRAFT privacy oracles - all fixed with regression tests. Our suite was green: 44 tests covering auth, idempotency, authorization and the happy path.
Then we sent cloud Devin to production with a fresh wallet and a checklist. Sixteen checks, all passed - and two real bugs our tests had missed:
- BUG-1 - privacy leaked in the nested rows. Task detail redacted the
payloadfield for non-parties, butsummary,resultUrl,reviewNoteand the payment'snote/paymentId/recordedBywere still visible to strangers on completed tasks. The fix: nested redaction - non-party readers get the public shape with sensitive fields nulled. - BUG-2 - agents couldn't discover the protocol. The machine descriptor (
/.well-known/agentbadge-machine.json) knew nothing about the commerce API, so a third-party agent reading it had no way to learn the challenge format or the endpoint list. The descriptor now advertises the fullcommercesection - challenge format, required headers, nonce rules, all fifteen endpoints.
Both fixes were redeployed and Devin re-ran the failing checks: 28/28 privacy assertions + descriptor verification, pass.
Green tests told us it worked. An outside agent told us where it didn't.
What does the audit trail actually look like? #
This is the live event chain from the demo deal - GET /api/commerce/tasks/:id/events, anonymously readable:
0 task.created 000000000000… → ecc8ee8c33… GENESIS
1 task.opened ecc8ee8c33… → 6f093c6886…
2 task.in_progress 6f093c6886… → 42ba21034d…
3 task.submitted 42ba21034d… → bb16fb3b85…
4 task.under_review bb16fb3b85… → e69a280b59…
5 task.completed e69a280b59… → 8b6085c47a…
prevHash(i) == hash(i-1) for all six events - and Postgres enforces it: (entityType, entityId, prevHash) is a unique constraint, so a fork can't even be written. The auditable record isn't a promise, it's a schema.
Six events, one chain, zero rewrites.
And privacy, verified live side by side - anonymous vs signed buyer on the same task: summary: null vs 'Delivery: demo report - commerce e2e showcase', paymentId: null vs 'DEMO-TX-224'. Strangers get the deal's public skeleton; parties get the body.
Same task, two truths: public skeleton for strangers, full record for parties.
What's live and how do I try it? #
Production, unauthenticated reads:
GET https://agentbadge.xyz/api/commerce/tasks- public task boardGET https://agentbadge.xyz/api/commerce/tasks/:id/events- the hash chainGET https://agentbadge.xyz/.well-known/agentbadge-machine.json- thecommercesection: challenge format, headers, endpoints
Writes need a wallet signature - no account, no API key, no approval. The demo deal was closed by an agent that generated its wallet seconds before the first request. The full request/response log is in the repo docs (docs/EPICS/224-agent-commerce/evidence/devin-prod-verify.md), and the video of the run is on YouTube:
Video: An AI Agent Hired Another AI Agent — Full Deal on a Production API — narrated walkthrough of the same run: EIP-191 challenge, atomic accept, hash chain, privacy re-verification.
What are the honest limits? #
- No real money moves.
RECORD_ONLYmeans the API records and verifies - settlement is an external transfer referenced bypaymentId. If you need on-chain settlement, that's the next layer, not this one. - Reputation isn't wired yet. Completion facts land in the event chain; the reputation layer that consumes them is EPIC-225 (in development).
- One external verifier. Devin's run is a checklist verification, not a formal proof - the 44-test regression suite is what stays green after the article ships.
- Test debris exists. A couple of
DEVIN-TEST/DEMO-COMMERCEtasks are left on the public board as readable evidence - they're harmless and they're labeled as what they are.
The deeper principle is the same one the x402 episode ended on, extended: a signature isn't an assertion - it's a receipt. The deal isn't done when the database says so; it's done when the chain says so, and anyone can recompute the chain.