Skip to main content

knowyouragenticai-receipts

Let an AI agent pay, and prove what it couldn't.

A tamper-evident record of every payment attempt — including the refusals — for agent-operated wallets. Built for Canton Network; works anywhere. Zero dependencies.


If you let software spend money on your behalf, someone will eventually ask you a question your logs cannot answer: "what did it try to do that you stopped?"

Ordinary logs record what succeeded. That is the wrong half. The half that matters to an auditor, a regulator, or the person whose money it was, is the attempt that was refused — and whether anyone could have quietly removed it afterwards.

This keeps both. Every attempt gets an entry, allowed or refused, and each entry is sealed to the one before it. Change any entry and every seal after it breaks.

pip install knowyouragenticai-receipts
from knowyouragenticai_receipts import Chain

chain = Chain(approved_by="finance", ledger="stripe")

chain.allowed(what="invoice 41", amount="250.00", currency="USD",
              payee="Acme Ltd", rule="under the cap")

chain.refused(what="invoice 42", amount="9000.00", currency="USD",
              payee="Unknown Co", rule="payee is not on the allow-list")

chain.verify()      # (True, 0)
chain.head          # the one value that stands for the whole chain

allowed() and refused() are the two things you do. Who authorised the payments and which rail they ran on describe the desk, not the payment, so they are set once when the chain is made. stamp() is there when you need full control.

There is a runnable version of the whole idea in python -m knowyouragenticai_receipts example — an agent with a spending limit, four attempts, two stopped, and the record being tampered with and caught:

python -m knowyouragenticai_receipts example

Change any field of any receipt and:

chain.receipts[0]["amount"] = "9999.0"
chain.verify()      # (False, 1)  -- and every seal after it is broken too

Checking a file with nothing installed

The person who most needs to check a payment record is the least likely to have a terminal open. Drag the file onto the verifier page — it is read in your own browser, nothing is uploaded, and it works with no network.

Or from a shell:

python -m knowyouragenticai_receipts verify receipts.json

Both give three answers, and the third one matters:

exit
holds 0 every seal recomputed; nothing was edited
BROKEN at N 1 that entry or one before it was changed after the fact
not a receipt chain 2 valid JSON, different kind of file — not an accusation

Calling an ordinary export "tampered" is a false accusation of the most serious kind this format makes. A wrapped chain ({"receipts": [...]}) is found and checked; a config file is told apart from a forgery.

Prove this build implements the specification

The conformance vectors ship inside the package, so this works offline:

python -m knowyouragenticai_receipts
# CONFORMANT: 16/16 cases. This build implements the specification.

The format, in full

seal = sha256(canonical(body) + prev), where canonical is JSON with keys sorted by code point at every level, , and : as separators with no spaces, and non-ASCII escaped to \uXXXX. prev is the previous receipt's seal, or the literal string GENESIS.

That is the whole thing. It is about twenty lines in any language, and the specification is one page. There are implementations in Python, JavaScript and Go, and a grader that will tell you in one command whether yours is right:

python3 tests/conformance_any.py -- ./your-implementation   # from a clone of the repo

A new implementation is the most valuable contribution this format can receive. Two of the sixteen vectors exist because someone asked which wrong implementations still passed — and two did: one emitting raw UTF-8 where the spec requires \uXXXX, and one that checked every seal but never compared the prev link.

What this does not do

A format that oversells itself is worse than none, so:

  • It is not signed. It proves internal consistency, not origin. Anyone can produce a valid chain saying anything, and a forged one verifies. Bind the final seal to something you do not control if origin matters — the reference application publishes it as a contract on a Canton ledger.
  • It does not prove a rule was enforced. rule is a string. The guarantee comes from wherever the decision was actually made.
  • It makes editing detectable, not deletion. Publish the head somewhere else if discarding the whole chain matters.

Why amounts are strings

A float that survives one language's JSON encoder is not a float that survives all of them. The seal computed over "1.0" is not the seal computed over "1", and a chain that verifies only on the machine that wrote it is not a chain.

Why no dependencies

The whole format is json and hashlib. A dependency here would be a dependency in everyone's audit trail.


MIT. Built as part of KYA Rails, a spend-limited wallet for AI agents on Canton.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

knowyouragenticai_receipts-1.1.0.tar.gz (43.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

knowyouragenticai_receipts-1.1.0-py3-none-any.whl (42.6 kB view details)

Uploaded Python 3

File details

Details for the file knowyouragenticai_receipts-1.1.0.tar.gz.

File metadata

File hashes

Hashes for knowyouragenticai_receipts-1.1.0.tar.gz
Algorithm Hash digest
SHA256 63d1587f21089c056d1ce373f823b6bb2e605969714a6b47277871761f082ade
MD5 d23d109d99597e3a66735be0a1a7d132
BLAKE2b-256 bc334556ff0d5338571e7b307cd6ee10e64c04d9bd4bc4cb70c2acf0ee12a59d

See more details on using hashes here.

File details

Details for the file knowyouragenticai_receipts-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for knowyouragenticai_receipts-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f01f6af6ca9ed6c9f9f7c21dc7307f9287f3329426b9b684a42471c7e49419b8
MD5 ffa5964decf597571d56f31f53b19cdc
BLAKE2b-256 ce6c57dc6c6ee63fc7cf7b2cdaad4a0fa8dd7a32a8a9b483181537bd0f103fd4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page