Worked example · agentic commerce · mesh-llm
Paid inference between strangers: two books, one payment.
On mesh-llm, a node can pay another node it has never met to run a model, over Lightning, with no one in the middle. This page shows how evidence and payment fit together in that exchange. Every claim below says what it rests on, and links it where the source is public.
payments.v1 plugin and the payer's payment.lifecycle.v1 events (#2035, merged 25 Sep 2026), in mesh-llm v0.77.0 (28 Sep 2026).The problem
One ledger cannot say why a payment is missing.
A provider serves a request and the payment never shows up in its wallet. From the provider's own records, three different stories look the same: an expired, unpaid invoice.
| What happened | What the payer's half shows | What the provider's half would show |
|---|---|---|
| Never paid | Terms accepted and an invoice received, then no settlement from its wallet. | The invoice lapsed, or a debt was recorded. |
| Paid late | Its wallet reported the payment, sealed after the invoice's expiry. | The invoice lapsed, then a late receipt arrived. |
| Noticed late | Its wallet reported the payment in time. | Its own wallet saw the payment only after its deadline check. |
Only the two halves together, joined on the payment_hash both wallets already share, separate the three. The payer's events are in mesh-llm v0.77.0, and the provider's (#2108) in v0.78.0. The times come from each side's sealed record. Each node's capsules plugin records the payment events its host reports, each with its source (plugin v0.1.0, 3 Oct 2026, and later). Joining the two sides' payment records to tell the three apart is not built yet: each node's Evidence page reads only its own book.
The architecture
Each node keeps its own book. Nothing sits in the middle.
The requester pays and the provider serves. Each runs mesh-llm with two plugins: payments.v1, which holds the wallet and does the paying or invoicing, and the Mesh-LLM capsules plugin, which seals that node's own half of the exchange where the host serves it. Each side's half commits to digests of the exact request and response, and never to the text itself.
1 · Serve
The requester sends the request with the provider's advertised prices. The provider prefills, then sends an input invoice with the terms frozen. It may decode ahead, but it pauses delivery at 512 tokens until its own wallet sees the payment.
2 · Pay
The payer pays the input invoice under its own spending cap. Output streams, and the provider invoices the output it actually sent. The payer settles that under the original authorization. Each moment appears on the payer's payment.lifecycle.v1 stream.
3 · Seal and close
At the end of the stream, each node's Mesh-LLM capsules plugin seals that node's half. Each node then sends its half to the other side, and on mesh-llm v0.78.0 or later the exchange is shown as confirmed by the other side when both sides recorded the same request and response digests. Checkpoints cover the new records, and a witness registers them if you turned one on.
The lifecycle
Six phases, and who asserts each one.
Every event carries a source, so a reader can see who is making the assertion. A signature on an event never upgrades it: a provider's claim stays a provider's claim.
| Phase | What it records | Who asserts it | Status |
|---|---|---|---|
| terms_accepted | The payer accepted the frozen terms; the amount is its approved cap. | payer_asserted | merged · #2035 |
| input_invoice_issued | The provider's input invoice, as the payer received it (not independently verified issuance). | provider_asserted | merged · #2035 |
| input_settlement_observed | The payer's wallet reported the input payment succeeded. | wallet_reported | merged · #2035 |
| output_invoice_issued | The provider's invoice for the output it sent, as the payer received it. | provider_asserted | merged · #2035 |
| output_settlement_observed | The payer's wallet reported the output payment succeeded. | wallet_reported | merged · #2035 |
| final_accounted | What the payer actually paid, fees included. | payer_asserted | merged · #2035 |
The provider's half, merged in #2108 (closing #2017), uses the same event shape plus role: provider, and is in mesh-llm v0.78.0 (4 Oct 2026). It covers the invoice as actually issued (provider_asserted) and its own wallet seeing the payment arrive (wallet_reported). It also records when delivery paused and resumed at the token gate (host_asserted), a lapsed invoice, the output delivered, and a debt recorded or forgiven. A forgiveness is an operator action, so it goes on the record. released · v0.78.0
What each party can show
Checkable by each side, without trusting the other's wallet.
The requester can show
- What it agreed to: a digest over the eight public fields of the terms, and nothing private.
- Whether and what its own wallet reported paying, keyed by
payment_hash. - Its sealed half of the exchange: digests of the exact request and response, and the token counts.
The provider can show
- Its sealed half of the exchange, including what it served and on which model file.
- With #2108, the invoices it actually issued, what its own wallet received, and when delivery was paused for payment.
- Which debts it recorded, and which an operator forgave.
Nobody takes on trust
- That the other side's record is the same: the halves match by digest, or they don't.
- That a record wasn't rewritten later: checkpoints commit to it, and a witness holds a copy of the checkpoint.
- Which side a claim came from: every event names its
source.
What no one can show from this, yet
- That the inference was correct, or that the prefill was honest. Upstream states that prices and token counts are the provider's claims, and that neither is checked.
- That a paid wallet belongs to any particular person or organisation.
- That every event was delivered. The stream is best-effort by design (an eight-event queue and a one-second timeout, and settlement never waits for it), so a missing event means incomplete evidence, not a failed payment.
What stays local
Prompt and response text, the invoice string, the payment preimage, wallet transaction IDs, and the private recovery ID never leave the node in these events or records. What travels is digests, amounts and payment_hash. Upstream notes that payment hashes are linkable metadata, so treat them that way.
For builders
Run it on two nodes
- Use mesh-llm v0.78.0 (4 Oct 2026) or later on both machines: it includes
payments.v1(#2035) and the provider-side events (#2108), so you see both halves. - Set up a wallet on each node as the upstream payments spec describes. Paid mode moves real money over Lightning. A paid provider must run a single-node text model.
- Install the Mesh-LLM capsules plugin on both:
# after downloading and checking the release archive mesh-llm plugins install --archive capsules-0.1.15-<target>.tar.gz \ --name capsules --version 0.1.15Each node now seals its own half of every exchange and checkpoints locally. With the default settings it sends its sealed record of a completed exchange only to the other side of that exchange. It also answers any node that asks, by an exchange's nonce, whether it holds its half of that exchange: ids and digests only, with no record content and not who the other side was (on by default since v0.1.9; setshare_exchange_corroboration = "off"to stop). Any node that asks also gets its checkpoint list andhistory_card/1: its signed checkpoints and the proofs between them, no records, whatever the settings. A witness is sent checkpoints only if you add one.
Released in v0.1.15 (3 Nov 2026): the Evidence page, and exchanges confirmed by the other side. Confirmation needs mesh-llm v0.78.0 or later on both nodes, and each node must know the other's key. Recording each payment event into the book, with its source, is released too (v0.1.0, 3 Oct 2026); the provider's events need mesh-llm v0.78.0. Not built yet: joining both sides' payment records to tell the three missing-payment stories apart.
For enterprises
Why this matters for agent payments
When your agents buy and sell work from parties you don't know, a dispute is settled by records, and one side's ledger is not enough to settle it. Here each party seals its own view at the moment of the exchange, and the two views join on an identifier both wallets already share, so "never paid", "paid late" and "noticed late" become checkable facts rather than accusations. No platform sits in the middle holding everyone's data: each party keeps its own book and shows only what a dispute needs.
When a dispute needs a second signature from someone who is neither party, that is what Countersign is for.
Claims table
Every claim on this page, and what it rests on.
Upstream links point at the mesh-llm pull request, issue or merge commit. Rows marked “released · ours” link a Mesh-LLM capsules plugin release and, where the release notes are not enough, its code at a named tag. Rows marked “designed” are not built yet.
| # | Claim | Status | Rests on |
|---|---|---|---|
| 1 | The mesh-llm host tells out-of-process plugins about each OpenAI exchange, including on the node that routed the request. | merged | #1437 · 6929c702887343af1b73296d7bd7f4aaa2db642f #1668 · 85b142df02fbb4c2555becd589ad7324296a8114 |
| 2 | That event carries digests of the exact request and response, plus serving provenance, so a half commits to digests and not text. | merged | #1841 · 6ffb2b711f081ca03bde7dc5bc9f8facec03da51 #1946 · 3060f3762aa92841be048113660eba07f2eab251 |
| 3 | The payments engine runs as the in-process payments.v1 plugin. It can be turned off, and with no engine installed the node runs free-only. | merged | #2035 · d06600ea0433a3271d0b51686ddb195f77a2336f |
| 4 | The payer emits payment.lifecycle.v1: six phases, each with a source of payer_asserted, provider_asserted or wallet_reported. | merged | paid_events.rs @ d06600ea0433a3271d0b51686ddb195f77a2336f |
| 5 | The terms digest covers eight public fields; the private recovery ID and the local peer are excluded. | merged | paid_events.rs @ d06600ea0433a3271d0b51686ddb195f77a2336f (terms_digest) |
| 6 | Events carry no invoice string, preimage, wallet transaction ID, prompt or response text, and payment hashes are linkable metadata. Delivery is best-effort: an eight-event queue, a one-second timeout, and settlement never waits for it. | merged | docs/specs/lightning-payments.md @ d06600ea0433a3271d0b51686ddb195f77a2336f |
| 7 | Two payments, input then output. Delivery pauses at 512 tokens until the provider's wallet sees the input payment. | merged | lifetimes.rs @ d06600ea0433a3271d0b51686ddb195f77a2336f (PRE_PAYMENT_OUTPUT_TOKENS) |
| 8 | An unpaid input invoice with nothing delivered lapses and does not block the peer. Delivered output left unpaid blocks the peer until it is paid or an operator forgives it. | merged | receivables.rs @ d06600ea0433a3271d0b51686ddb195f77a2336f |
| 9 | Prices and token counts are the provider's claims. Correct inference and honest prefill are not checked. | merged (stated) | docs/specs/lightning-payments.md @ d06600ea0433a3271d0b51686ddb195f77a2336f (Payment flow) |
| 10 | payments.v1 is in a tagged release: #2035 merged on 25 Sep 2026, and mesh-llm v0.77.0 (28 Sep 2026) includes it. | fact | mesh-llm v0.77.0 · #2035 |
| 11 | The provider's matching events use the same shape plus role: provider, including host_asserted delivery pause and resume, lapse, and debt recorded or forgiven. They join on payment_hash. | released · v0.78.0 | #2108 · issue #2017 (closed as completed, 30 Sep 2026) |
| 12 | The Mesh-LLM capsules plugin installs with one command and seals each node's own half at the serving boundary. Local checkpoints are on by default, and the witness is off unless you set its URL. | released · ours | Mesh-LLM capsules plugin v0.1.15 · 3b3538179c50ca11c5266d6c0bb3aaca677d5fb3 |
| 13 | Each node sends its half to the other side at completion, on by default, and an exchange whose two halves agree is shown as confirmed by the other side. This needs mesh-llm v0.78.0 or later on both nodes, and each node must know the other's key. | released · ours | Mesh-LLM capsules plugin v0.1.15 (What works today) · 3b3538179c50ca11c5266d6c0bb3aaca677d5fb3 exchange-row-state.ts @ 02ee5c9bbbad32de9037c7b8d4aaab10bf0f911d (deriveRightCellState) |
| 14 | The plugin adds an Evidence page to the mesh-llm console: the peers this node exchanged with, each exchange and whether it is confirmed by the other side, and whether this node's log still verifies. | released · ours | Mesh-LLM capsules plugin v0.1.15 · 3b3538179c50ca11c5266d6c0bb3aaca677d5fb3 |
| 15 | The Mesh-LLM capsules plugin reads payment.lifecycle.v1 and seals each event its own host reports as a record with its source, refusing an event relayed from a peer. Each node's Evidence page shows a paid exchange's amounts from those records, and who stated each. Sealing is in the plugin from v0.1.0 (3 Oct 2026); the Evidence page view from v0.1.4 (12 Oct 2026). | released · ours | main.rs @ 02ee5c9bbbad32de9037c7b8d4aaab10bf0f911d (payment.lifecycle.v1 handler) settlement_channel.rs @ 02ee5c9bbbad32de9037c7b8d4aaab10bf0f911d (source kept) Mesh-LLM capsules plugin v0.1.4 (paid exchanges on the Evidence page) |
| 16 | The three missing-payment stories are told apart by joining both sides' payment records on payment_hash. Not in the plugin yet: each node's Evidence page reads only its own book, and an invoice with no settlement its wallet reported reads as “no settlement seen”, with no reason given. | designed | DESIGN-paid-inference-evidence.md @ v0.1.0 evidence_panes/settlement.rs @ 02ee5c9bbbad32de9037c7b8d4aaab10bf0f911d (one node's book only) |
More worked examples, with reports you can open and check: Demos →