{"slug": "slothpay-the-sloth-that-pays-for-you-fail-closed-agent-payments-with-a-local-3", "title": "SlothPay: the sloth that pays for you - fail-closed agent payments with a local Gemma 3", "summary": "A developer built SlothPay, an open-source, fail-closed agent payment tool that lets software autonomously settle machine-payable HTTP (x402) requests within user-defined price ceilings and nightly budgets. The tool runs a local Gemma 3 1B model on llama.cpp for morning digests and wake/sleep triage in strict JSON, while all arithmetic is handled by Python's Decimal to prevent the model from hallucinating prices. In a demo sweep of three mock sellers, SlothPay paid the well-behaved $0.05 endpoint, denied a hostile one for insufficient challenge entropy, and skipped a free resource.", "body_md": "*This is a submission for the [Hacktoberfest Open-Source AI Challenge Week 3: Slow and Steady](https://dev.to/challenges/hacktoberfest-week3-2026-10-19)*\n\n**[SlothPay](https://github.com/eddyflores100-lang/slothpay)** — the sloth that pays for you.\n\nMachine-payable HTTP (the x402 flow, where a server answers `402` with a price and your software just... pays) is powerful and slightly terrifying: your software can spend money while you are not looking. The usual answers are a cloud dashboard, a closed trust API, or another subscription. SlothPay is the lazy, local answer.\n\nYou tell it **once** which resources your agents may buy and up to what price. Every night it:\n\n`402 Payment Required`, it reads the seller's Who gets to be lazier? Anyone whose agents buy things from machines — API consumers, agent-framework users, tinkerers running local automation. You never review trust paperwork and you never click \"buy\" for a $0.05 endpoint again. You sleep; the sloth settles.\n\nEverything below is a real transcript from the repo's demo — one mock seller serving three resources: a well-behaved one, a hostile one shipping a real (bad) credential, and a free one.\n\n``` php\n$ slothpay sweep\n🦥 sloth wakes. budget 1.00 USD, spent tonight 0 USD\n\n-> http://127.0.0.1:8402/api/sleep-sounds\n   PASS R0 signature verifies (demo crypto)\n   PASS R1 amount_usd fixed-scale string ok\n   PASS R2 challenge entropy ok (24 bytes)\n   PASS R3 pin 'seller-demo-key-2026' present and in-window\n   PASS R5 issued_at/expires_in present and sane\n   PASS R6 credential inside validity window / resource binding ok\n   PASS R4 verifier confirmed\n   verdict: PASS — all rev-4 checks passed\n   PAID (200) — verified + $0.05 <= ceiling $0.50 + budget ok\n\n-> http://127.0.0.1:8402/api/night-report\n   FAIL R2 challenge entropy < 128 bits (5 bytes)\n   DENY — trust check failed\n\n-> http://127.0.0.1:8402/api/free-tips\n   200 — free, the sloth naps\n```\n\nMorning:\n\n``` bash\n$ slothpay digest\nPaid 1 of 3 requests, total $0.05.\nInsufficient funds or trust violation – request denied.\n```\n\nThe project is also live on **[https://utalabs.tech](https://utalabs.tech)** (a landing with the full story; it currently serves the workers.dev mirror while DNS propagates).\n\n**[github.com/eddyflores100-lang/slothpay](https://github.com/eddyflores100-lang/slothpay)** — Apache-2.0, Python 3.12+, **zero required dependencies** (the optional Gemma path uses llama.cpp).\n\nInside:\n\n`slothpay/verify.py` — the fail-closed verifier (R0–R6, every branch testable)`corpus/vectors.json` — a `slothpay/policy.py` — the lazy policy engine: ceilings, nightly budgets, allow/deny lists`slothpay/llm.py` — the local brain: Gemma writes the morning note; `Decimal`, never by the model` demo/mock_seller.py` — stdlib-only x402-shaped seller, hostile variant included`tests/` — 8 tests including a full end-to-end sweep; all green\nThree open pieces hold the whole thing together — none of them closed:\n\n**Gemma 3 1B (open-weight) on llama.cpp, CPU-only.** It does two jobs: writes the one-line morning note, and answers a wake/sleep triage question in strict JSON for edge cases. I deliberately did *not* let it do arithmetic — a model hallucinating a price is the one sloth sin I don't allow. So Gemma writes the commentary; Python's `Decimal` writes the numbers. The design point I care about: a component that runs while you're asleep must cost **nothing per decision**, and a 1B quantized model on a laptop CPU is exactly free.\n\n**x402 (open protocol).** The client conversation is x402-shaped: `402` → `PAYMENT-REQUIRED` (carrying the seller's credential and pinset reference) → `PAYMENT` retry. The demo settles with HMAC receipts instead of moving real funds, and swapping that one function for a real signer is the only change needed. Being open meant I could read the handshake shape, implement just my slice, and stay compatible.\n\n**ATC/1.0 (open trust spec).** The credential verification implements the §5 payment-credential profile from the openly published Universal Trust Adapter proposal, with the rev-4 hardening: fixed-scale `amount_usd` strings (≤ 6 dp), seller-minted challenges with ≥ 128 bits of entropy, `kid`/pinset windows (` not_before`/` not_after`), mandatory `issued_at`/` expires_in`, and — my favorite rule — *if the trust verifier can't be reached, you deny. Never fail-open.* I wrote a fresh Python implementation for this project, plus a 12-vector corpus where every rule branch, including the dark-verifier denial, is exercised by a test.\n\nA closed \"trust-as-a-service\" API could have shipped a demo like this faster. It could not have shipped *this* project, for three concrete reasons:\n\n**Auditable decisions.** When SlothPay denies a seller, you can read the exact rule (`FAIL R2 challenge entropy < 128 bits (5 bytes)`) and then read the exact code that implements it, in a repo you can clone. Trust logic you can't read is just a black box with a logo — and this project's entire job is deciding who may spend your money. Closed would have defeated the point.\n\n**Your money, your machine.** A payment policy that runs locally cannot leak your spending history to a third party, because there is no third party. It also cannot be shut off, repriced, or deprecated under you at 3am — which is precisely when an overnight agent would be running.\n\n**Swappable everything.** Want Ed25519 instead of the demo HMAC? A bigger open model? Your own verifier network? Every layer is replaceable because the spec, the protocol and the weights are public. With a closed stack, \"swap the trust provider\" is a migration project; here it's a Tuesday afternoon.\n\nAnd the quiet one: **it can exist at all.** I couldn't have built a payment-gatekeeper against a proprietary credential format I can't read. Open specs let a weekend project touch money-grade problems safely.\n\nI built this with an AI coding agent, so showing the work matters to me. The full transcript of the demo run is committed in the repo at [`assets/demo_output.txt`](https://github.com/eddyflores100-lang/slothpay/blob/main/assets/demo_output.txt) (byte-for-byte what you saw above, nothing staged), the rule-by-rule verifier trace is part of every sweep, and the commit history shows the build order: verifier → corpus → policy → client → seller → digest. A DevRelay session embed is coming as an update before submissions close.\n\nThe honest numbers from this week:\n\n`policy.json` with your ceilings and budget. I have not touched mine since.\nSlow and steady settles everything — including the invoices.", "url": "https://wpnews.pro/news/slothpay-the-sloth-that-pays-for-you-fail-closed-agent-payments-with-a-local-3", "canonical_source": "https://dev.to/edison_flores_6d2cd381b13/slothpay-the-sloth-that-pays-for-you-fail-closed-agent-payments-with-a-local-gemma-3-1kkc", "published_at": "2026-10-20 19:14:02+00:00", "updated_at": "2026-10-20 19:18:48.243557+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "large-language-models", "agent-protocols", "ai-safety"], "entities": ["SlothPay", "Gemma 3 1B", "llama.cpp", "x402", "ATC/1.0", "Hacktoberfest", "utalabs.tech"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/slothpay-the-sloth-that-pays-for-you-fail-closed-agent-payments-with-a-local-3", "markdown": "https://wpnews.pro/news/slothpay-the-sloth-that-pays-for-you-fail-closed-agent-payments-with-a-local-3.md", "text": "https://wpnews.pro/news/slothpay-the-sloth-that-pays-for-you-fail-closed-agent-payments-with-a-local-3.txt", "jsonld": "https://wpnews.pro/news/slothpay-the-sloth-that-pays-for-you-fail-closed-agent-payments-with-a-local-3.jsonld"}}