feat: @x402/mnemopay — economic memory for AI agent payments#1904
feat: @x402/mnemopay — economic memory for AI agent payments#1904t49qnsx7qt-kpanks wants to merge 1 commit intox402-foundation:mainfrom
Conversation
AI agents using x402 today are stateless — they pay and forget. This package layers MnemoPay's economic memory on top of x402 payment flows so agents remember costs, track endpoint reliability, and build reputation from real payment outcomes. - withMnemoPay() wraps any x402-enabled fetch with memory operations - Before each request: recall() checks past payment experiences - On success: settle() reinforces the positive memory (+reputation) - On failure: refund() docks the memory (-reputation) - recallEndpointInsight() surfaces cost history and success rates - Full test suite with 14 tests covering all payment flow paths - Follows existing x402 package structure (tsup, vitest, eslint) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🟡 Heimdall Review Status
|
|
@t49qnsx7qt-kpanks is attempting to deploy a commit to the Coinbase Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey team! Added a live interactive demo to the PR description: try it here. It shows the feedback loop in action — an agent hiring freelancers, learning from settlements and refunds, and consistently picking the best value by round 7-8. The core idea: |
|
One pattern we're exploring for agent-to-agent payment contexts: if the payer agent is operating through a managed custody layer (rather than controlling its own signing key), the PAYMENT-SIGNATURE header is technically signed by the custodian infrastructure, not the agent's x402 identity. This creates an attribution gap where the payment is valid on-chain but the agent's reputation history in ERC-8004 doesn't accrue correctly. |
|
@postmode Great question — this is exactly the kind of edge case that matters for production agent deployments. Short answer: MnemoPay sidesteps this problem by design. The wallet is agent-local, not custodial — the agent holds its own signing key and produces the Here is how the pieces fit together:
For the managed-custody pattern you describe, the attribution gap is real and I think it is fundamentally a facilitator-spec concern — the spec would need a way to bind a delegated signer to the logical agent identity (something like an Happy to dig deeper on any of this. |
Hey — thanks for the context on the issue thread. Building the financial infrastructure layer for agent deployers — custody, yield routing, and ERC-8004 reputation signals as a managed service. The x402 + ERC-8004 combination is exactly the rail we're building on. Would love 20 minutes at some point — specifically interested in who in the Coinbase ecosystem you think is doing the most serious infrastructure work on x402 right now. Happy to share what we're building in exchange. |
|
@postmode — custody + yield routing + ERC-8004 reputation as a managed service is a compelling stack. That's essentially the infrastructure layer that makes agent-local signing practical at scale, which is the exact gap between "works in a demo" and "works in production." Would love to do the 20 minutes. I'm flexible on timing — drop a Calendly link or propose a couple of slots and I'll lock one in. On the Coinbase ecosystem question — happy to share what I've seen from working through this PR and the x402 spec. There are a few teams doing interesting things on the facilitator side that would be worth discussing live rather than in a comment thread. Likewise keen to hear how you're thinking about the custody-to-reputation mapping. Your original question about the attribution gap when a custodian signs on behalf of an agent is the right problem — if you're building the managed custody layer, you're in the best position to define how that delegation gets expressed in the payment header. That could be a useful input to the x402 spec itself. Looking forward to it. |
|
Appreciate looking at it! In the meantime, here is the thesis that
addresses the issue. I am inviting you to take a look at it—link: (
https://cutt.ly/ytScNJba)
…On Sat, Apr 4, 2026 at 12:48 AM t49qnsx7qt-kpanks ***@***.***> wrote:
*t49qnsx7qt-kpanks* left a comment (x402-foundation/x402#1904)
<#1904?email_source=notifications&email_token=BACX6JMVFGHR6UTXARWTOND4UABQHA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJYGQ3TGMBQHA32M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJNLQOJPWG33NNVSW45C7N5YGK3S7MNWGSY3L#issuecomment-4184730087>
@postmode <https://github.com/postmode> — custody + yield routing +
ERC-8004 reputation as a managed service is a compelling stack. That's
essentially the infrastructure layer that makes agent-local signing
practical at scale, which is the exact gap between "works in a demo" and
"works in production."
Would love to do the 20 minutes. I'm in Lagos (WAT / UTC+1) but flexible
on timing — early mornings or evenings work well for US timezones. Drop a
Calendly link or propose a couple of slots and I'll lock one in.
On the Coinbase ecosystem question — happy to share what I've seen from
working through this PR and the x402 spec. There are a few teams doing
interesting things on the facilitator side that would be worth discussing
live rather than in a comment thread.
Likewise keen to hear how you're thinking about the custody-to-reputation
mapping. Your original question about the attribution gap when a custodian
signs on behalf of an agent is the right problem — if you're building the
managed custody layer, you're in the best position to define how that
delegation gets expressed in the payment header. That could be a useful
input to the x402 spec itself.
Looking forward to it.
—
Reply to this email directly, view it on GitHub
<#1904?email_source=notifications&email_token=BACX6JMVFGHR6UTXARWTOND4UABQHA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIMJYGQ3TGMBQHA32M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJNLQOJPWG33NNVSW45C7N5YGK3S7MNWGSY3L#issuecomment-4184730087>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BACX6JMNK2KTRSAZLPAVCML4UABQHAVCNFSM6AAAAACXKEOZ6SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DCOBUG4ZTAMBYG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Hey @postmode -- following up on your note about custodial signing, ERC-8004 reputation signals, and MnemoPay integration. Really interested in exploring how ERC-8004's reputation framework could complement MnemoPay's trust scoring on the payment side. Happy to do that 20-minute call today (April 4) if your schedule allows. Feel free to DM me on X (@jerryomiagbo) or shoot me an email at jerry@mnemopay.com and we can lock in a time that works for you. Looking forward to it! -- Jerry Omiagbo, MnemoPay |
|
Quick correction on my contact info above — best way to reach me is jeremiah@getbizsuite.com. Looking forward to connecting today, @postmode. |
|
The statefulness problem is real and economic memory is the right framing. But there's a gap between "agent remembers what happened" and "agent can prove what happened." MnemoPay gives agents memory — they recall past payment experiences. What's missing is non-repudiation: the ability for a third party (auditor, counterparty, dispute resolver) to verify that the agent's memory is accurate and hasn't been tampered with. We built this in the Agent Passport System. Every payment decision produces a signed receipt: {
"action": "x402_payment",
"endpoint": "api.example.com/data",
"amount": "$0.01",
"scope_check": "permit",
"delegation_remaining": "$1,847.23",
"previous_receipt_hash": "sha256:9f8e7d...",
"signature": "ed25519:..."
}The receipts form a hash chain — tamper with any entry and the chain breaks. This means the agent's economic memory is verifiable by anyone, not just the agent itself. The convergence point: MnemoPay's Concrete integration: Published on npm as |
|
The non-repudiation gap is real — I've been aware of it but deliberately punted, wanted the memory layer to stabilize before adding cryptographic guarantees. The hash chain approach is cleaner than what I was sketching (was thinking append-only logs with merkle roots, but receipt-per-action is more granular and queryable). The Looked at agent-passport-system. The Happy to sync on this — these two feel genuinely complementary rather than overlapping. What's your current approach to key lifecycle (rotation, revocation) on the passport side? |
|
Good questions — all three matter for production integration. Signing timing: Receipt is signed after payment outcome resolution, but the receipt body includes the full lifecycle: intent (pre-payment), evaluation (scope check), and outcome (settled/failed/timeout). Failed payments get receipts too — the Key lifecycle:
On co-signing: MnemoPay holding the signing key is architecturally clean for the memory+audit convergence. The alternative that preserves separation of concerns: MnemoPay calls const receipt = await passport.receipts.sign({
action: 'x402_payment',
endpoint: outcome.endpoint,
amount: outcome.amount,
settled: outcome.settled,
mnemopay_reputation: outcome.reputationDelta
});
// MnemoPay stores the receipt hash as its memory entry
await mnemopay.remember(receipt.hash, outcome);One key material, two consumers. The reputation score references the receipt hash, so it's always traceable back to cryptographic proof. Want to try a minimal integration? I can set up a test fixture on npm that exports the signing function standalone. |
|
The key rotation design you laid out is solid — cascade revocation on validUntil makes sense, and I like that the agent holds the private key rather than the principal. Clean separation. Honest answer: the signing layer is the right architectural direction but I'm not building it yet. I want to validate that developers actually want persistent agent memory before I add the verifiability layer on top. Every time I've jumped ahead to the hard protocol problem before confirming anyone needs the basic thing, it hasn't gone well. If you end up putting together that test fixture on npm I'd be interested to see how the receipt hash integrates with the memory store — the pattern you sketched makes sense. Are you actively building with x402 + something like this, or is it more exploratory right now? |
Summary
AI agents using x402 today are stateless — they pay the 402, get the resource, and immediately forget. They never learn which endpoints are cheap, which are reliable, or which alternatives exist. This PR adds @x402/mnemopay, a middleware package that gives x402 agents economic memory via MnemoPay.
What it does
withMnemoPay()wraps any x402-enabled fetch function and adds four memory operations around each payment:recall()charge()settle()→ +reputationrefund()→ -reputationOver time, agents build a knowledge base of endpoint costs, reliability rates, and alternatives — turning every payment into a learning event.
Why this matters
The x402 protocol is uniquely positioned for AI-native commerce. But stateless payments leave value on the table. An agent that remembers its payment history can:
Usage
Package details
typescript/packages/http/mnemopay/@mnemopay/sdkis a peer dependency — no new runtime deps in x402 coreMnemoPayAgentinterface so users can bring their own implementationTest plan
withMnemoPay()passes through non-402 responses unchangedrecall()is called before each request with the endpoint URLsettle()is called on successful paymentsrefund()is called on failed paymentstsupand follows the existing dual CJS/ESM export pattern@x402/fetchand@x402/axioswrapped functions🤖 Generated with Claude Code
Live Demo
Try it now: https://t49qnsx7qt-kpanks.github.io/mnemopay-demo/
The Feedback Loop in 30 Seconds
How it works
5-line integration