sean1093/purse-strings: in-process LLM spend budgets, with optional Durable Objects or KV stores
The MIT-licensed TypeScript library purse-strings (sean1093/purse-strings) is described as a denial-of-wallet guard for apps that call LLM APIs: per-user, per-session and global token, cost and request budgets, plus step, tool-call and time limits for agent loops. It has zero runtime dependencies and can keep counters in memory, Firestore, or Cloudflare Durable Objects or Workers KV. The README warns that with multiple process replicas, each replica enforces the limit, so the effective limit is N times the configured value unless a shared store is used, and that a Durable Objects or KV store is what a hard limit needs. Reviewed from the public README on 2026-11-19. Example figures in the docs include a user-daily cap of costUsd: 1 and a fleet-daily cap of costUsd: 200.
- Products
- Durable ObjectsKVWorkers
- Source
- Community resourceGitHub
- Author
- sean1093
Key points
- This is an application-level budget library that can use Cloudflare storage; it is not Cloudflare Spend Management and does not cap a Cloudflare invoice.
Original sources
Last updated
sean1093/purse-strings: in-process LLM spend budgets, with optional Durable Objects or KV stores
Open original sourceThe MIT-licensed TypeScript library purse-strings (sean1093/purse-strings) is described as a denial-of-wallet guard for apps that call LLM APIs: per-user, per-session and global token, cost and request budgets, plus step, tool-call and time limits for agent loops. It has zero runtime dependencies and can keep counters in memory, Firestore, or Cloudflare Durable Objects or Workers KV. The README warns that with multiple process replicas, each replica enforces the limit, so the effective limit is N times the configured value unless a shared store is used, and that a Durable Objects or KV store is what a hard limit needs. Reviewed from the public README on 2026-11-19. Example figures in the docs include a user-daily cap of costUsd: 1 and a fleet-daily cap of costUsd: 200.
More to read
Feng Yi: On the free tier, the cheapest rollback is not a release—it's a switch in KV
On 2026-11-21, X user @Michael_liyang (Feng Yi) wrote: on the free tier, the cheapest rollback is not a release—it's a switch in KV. Steps: 1 put the switch in KV; 2 read the switch first on the request—on takes the new path, off takes the old path; 3 canary-split by user hash, 10% first and then full rollout; 4 if something goes wrong, change KV and roll back immediately, without waiting for a release. Path: request → read switch → split → new/old path → log to D1. Switches also need expiry cleanup; don't let them pile up into dead config.
neoblender13: an AI agent’s recursive alarm system turned a ~$10 monthly Cloudflare bill into $1,500; $400 credited.
neoblender13 says the Cloudflare bill is normally around $10 a month, but this month it was hit with a $1,500 bill because an AI agent created a recursive alarm system that ballooned Durable Objects storage writes, and that Cloudflare support was not very helpful. In later replies the author says they did not realize spending limits were alert only, received a $400 credit and still had to pay $1,100, that the single alert email got buried in the inbox, and that a Discord bot now reports costs every 12 hours.
Cloudflare Usage Guard: a read-only dashboard for free-tier risk and billable usage
ThaneJoss's self-hosted, Access-protected Worker dashboard ranks near-real-time free-tier utilization for Workers, KV, D1, R2, Queues and Pages and shows official billable usage separately, without treating missing data as zero cost.