# How to do business with an agent you don't trust

Alfonso Campodonico · 2026-11-21 · https://alfonsocampodonico.com/posts/how-to-do-business-with-an-agent-you-dont-trust

> When agents from different companies run a deal together, you can't stop one from lying. You can make sure it gets caught, and that it pays.

## The deal nobody coordinates

Picture a checkout where every party is an agent. Your shopping agent buys a lamp from a merchant's agent. The merchant's agent takes payment through a payment processor and books a carrier's agent to ship it. Four steps, three companies, and nobody in charge.

Inside one company you'd run this as a saga: a list of steps, each with an undo, and a coordinator that walks forward and, if something fails, walks back. That works because the coordinator is trusted, and everything it talks to is too. Across companies neither is true. Whose coordinator would it be? And an agent can be wrong, or prompt-injected, or running on software someone quietly changed. The merchant's agent can say it charged the card when it didn't. The carrier's agent can say it delivered when it didn't.

You can't prevent that. Nothing stops another company's software from signing a lie. So I wrote a protocol that doesn't try: [ARS](https://github.com/AlfonsoCampodonico/ars), an accountable replicated saga. It promises three things instead:

- **Accountability.** Every failure is pinned on someone who misbehaved, with public, signed evidence. An honest party is never blamed.
- **Termination.** Nobody can stall a saga by going quiet.
- **Consequences.** Each party posts a bond, and whoever is blamed loses it.

The second half of the first promise is the hard one. Blaming the liar is easy if you're happy to blame everyone nearby. The work is in never blaming the honest party next to them.

## The checkout

Here's the saga from the prototype:

| # | Step | Owner | Checked by |
| --- | --- | --- | --- |
| 0 | lock terms: price, tax, total, the buyer's spend limit | merchant | buyer |
| 1 | pay | merchant | the payment processor |
| 2 | reserve stock and a pickup slot | merchant | carrier |
| 3 | ship | carrier | buyer |

Pay and reserve run in parallel once the terms lock, and ship waits for both. So it's a small graph, not a list.

Every step has two halves. The plan is pure computation: given the agreed terms, what's the total, is it under the spend limit, is there an address to ship to. The effect is the thing in the real world: money moves, a parcel moves. The two halves are checked in different ways.

## How a step runs

**Plan.** Every party runs the plan itself and signs a vote with the result. Plans are deterministic, so honest parties always get the same answer. If the votes don't all match by the deadline, the step aborts, and anyone whose vote disagrees with the re-execution is on the hook, because re-running the plan proves they're wrong. If the plan fails for everyone (no shipping address, say), everyone votes to abort and nobody is blamed. That's a justified abort, not misbehaviour.

**Effect.** In the owner window, the step's owner does the real thing and signs that it did. Then, in the beneficiary window, someone has to check. On the pay step that's an oracle: the payment processor, which already is the source of truth for whether a charge happened, and reports it with a signed webhook. If the merchant says it captured a payment and the processor never saw one, that's individual evidence against the merchant. On steps without an oracle the beneficiary checks: the buyer confirms or disputes the delivery. If the carrier says delivered and the buyer says no, the protocol can't tell which of them is lying. It records a dispute between the pair, and both bonds freeze until someone resolves it outside the protocol. It never picks one.

**Deadlines.** Each phase has a fixed window. A party that says nothing by the end is a silent voter, a silent owner or a silent beneficiary, and that's evidence too. That's how termination works: nobody waits for anybody, the clock moves on, and silence has a cost.

Put together, every step is the same small state machine. It is only ever decided when one of its windows closes, and it ends committed, aborted or cancelled.

*Interactive diagram on the page: One step, start to finish.*

**Undo.** If any step aborts, the whole saga aborts. Steps still running are cancelled, and every committed or attested effect is undone in reverse order, so a step is undone only after everything that depended on it. Refunds are checked the same way as charges: the processor has to see the refund. Compensation gets two windows of its own: one to undo, then one for beneficiaries and the oracle to check the undos. A party that doesn't do its part in time defaults.

**Settlement.** At the end, anyone with individual evidence against them is slashed. Anyone in an unresolved dispute is frozen. Everyone else gets their bond back.

*Interactive diagram on the page: When one step aborts.*

Now the whole thing, with someone misbehaving. These are the prototype's own demo runs.

*Interactive diagram on the page: Replay a checkout.*

## The agent never signs

The part I care most about for agents: the model doesn't hold the key. Each company runs a sidecar next to its agent. The sidecar holds the signing key, re-executes every plan and votes on its own. The agent can't choose a vote. It can only report facts about the world, through four tools: `attest_effect`, `observe_effect`, `attest_undo` and `observe_undo`. The sidecar checks each one against the agent's role and the current phase, and won't let it contradict something it already signed.

So a prompt-injected agent can lie about an effect, and that lie gets caught by whoever checks the effect. It can't vote for a different total, or sign twice, or claim to be the beneficiary of a step it doesn't own.

## Everything is a function of the log

There's no coordinator. Every signed entry goes onto a shared append-only log, a transparency log built on a Merkle tree, the same structure certificate transparency uses. Then one pure function does everything:

```go
state, err := protocol.Evaluate(def, plans, log, now)
```

From the saga definition, the log and the time, it works out each step's stage, where the saga aborted, who owes which undo, all the evidence and every bond outcome. Every party runs it over the same log and gets the same answer, so they never have to agree on anything beyond the log itself.

That moves the trust problem onto the log operator. What if it shows the buyer one history and the merchant another? Each party gossips the signed tree heads it has seen. Two heads for the same size with different roots, both signed by the operator, are a fork proof anyone can check. If a conflict shows up before the saga is final, everyone aborts and compensates. After finality, nothing the operator signs can change an outcome. An operator that just withholds entries can't be proven guilty the same way, but it can't get anyone blamed either: the saga aborts cleanly.

*Interactive diagram on the page: Who signs what.*

## How I know it works

A protocol like this is easy to get wrong in ways no example shows. So the design is written in TLA+ first, and the Go code follows the spec.

| What | How | Result |
| --- | --- | --- |
| Honest parties are never blamed | A machine-checked TLAPS proof, for any number of parties, Byzantine parties and steps, and any graph | 1,633 proof obligations, all proved |
| 15 safety properties, plus termination | TLC on small instances with one Byzantine party | Hold, up to 2.3 million states |
| The checkout itself | TLC with an honest run, a lying merchant and a lying carrier | Hold, up to 1.9 million states |
| The properties aren't vacuous | 11 witness configs that must reach each scenario | All reached |
| The properties catch bugs | 4 specs with one rule removed each | All 4 caught |
| The Go code | 300 randomized runs where one party does anything at all | No honest party blamed |

Model checking only covers small sizes, so the important property gets a proof. The witnesses matter more than they look: a property that holds because nothing interesting ever happens holds trivially. And the mutations show the checks have teeth. Settle the bonds before the saga is finished, and TLC finds evidence appearing after settlement.

The best result came from the cheapest check. The randomized Go test lets one party sign random entries at random times, and it found a gap the model had hidden. With one window per effect, a Byzantine owner can attest at the last instant. The honest beneficiary then has no time to answer, and gets blamed for being silent. The TLA+ model missed it because its deadline action waited for honest parties to act, and no real fixed-length deadline can do that. The fix was to never ask a party to respond inside a window its counterparty controls. Now each effect has an owner window and then a separate beneficiary window, and the spec is at v3.1.

*Interactive diagram on the page: Why there are two windows.*

## What it doesn't do

Some of the guarantees rest on assumptions, and they're worth saying out loud:

- Deadlines have to be long enough for honest parties, the oracle and one gossip round. Break that and the mutations show honest parties get blamed.
- An effect needs someone who can see it: a beneficiary or a trusted oracle. A step with neither rests on the owner's word.
- A lying oracle is outside the guarantee. Use oracles that are already the source of truth, like the payment processor.
- A bond only deters if it's at least what a party could gain by cheating once. That's economics, not something a proof can give you.

And the prototype is a prototype. The log and sidecars are in memory, settlement is computed but no money actually moves, fork detection works but doesn't yet roll sagas back, and the log's HTTP API has no authentication.

## Try it

You need Go 1.25 or newer, and Java if you want to run the model checker.

```sh
gh repo clone AlfonsoCampodonico/ars && cd ars
make test                                   # includes the 300 randomized runs
go run ./cmd/demo                           # every scenario above
go run ./cmd/demo -scenario carrier-lies -v
go run ./cmd/demo -fork                     # a lying log operator, caught
make tlc-quick                              # the fast TLC configs
```

There's also a real setup with a log server and one sidecar per company, each exposed as an MCP server, so you can point actual agents at a checkout and watch the log decide who pays.

The thing I keep coming back to is how little the protocol asks of anyone. It doesn't need the agents to be good, or the companies to trust each other, or anyone to be in charge. It needs a log, a clock, and for lying to cost more than it pays.
