Inspiration
Coding agents burn most of their money re-reading context: CI logs, stack traces, whole source trees, all sent to expensive models. Compression fixes the token bill, but an agent working at 2 a.m. can't stop and ask a human for a credit card every time its compression credits run out. We wanted an agent that can pay for its own tools on its own, the way a person would, but inside limits the human actually trusts.
What it does
ContextPay gives a coding agent a prepaid wallet with a mandate:
- You save a PayPal wallet once (PayPal Vault) and set rules: max per purchase, max per day, and the minimum return a purchase must promise.
- The agent compresses its context through ContextPay. When credits run out, the endpoint returns
402 Payment Required. - A Claude planner decides whether buying more credits is worth it and how much, based on the upcoming job, the savings measured so far, and both prices.
- Inside your limits, the agent charges your saved PayPal wallet itself (merchant-initiated) and keeps working.
- Over your limits, it stops and asks you. Approve with one click on the dashboard to charge the saved wallet (no PayPal redirect), or pay through a regular PayPal checkout, or deny. The agent resumes where it stopped.
The model proposes; the code decides. Spending limits are enforced in src/mandate.js after the planner runs, so no model output can spend past them.
How we used PayPal
- Vault v3 (
/v3/vault/setup-tokens, buyer approval,/v3/vault/payment-tokens) to save a wallet the agent may charge later. - Orders v2 with
payment_source.paypal.vault_idandstored_credentialfor agent-initiated, unscheduled merchant charges with no human present. - One-click approval: when a purchase is over the limit, the human approves it on the dashboard and ContextPay charges the same saved wallet, so approving takes one click instead of a full checkout.
- Orders v2 checkout and capture for over-limit purchases when the human prefers PayPal checkout, and for manual top-ups.
- Every call sends a
PayPal-Request-Id, and concurrent 402s coalesce into a single purchase, so a retry never double-charges.
How we used AI
A Claude purchasing planner (structured output) reads the upcoming job, the measured savings so far, prices, and the mandate, and returns a buy or decline decision with an amount and a one-line rationale shown on the dashboard. A deterministic heuristic stands in when no API key is present, which is what the hosted demo uses.
Sponsor tools
- AG Grid: the purchase ledger (who asked, amount, outcome, why it was blocked, PayPal order id, planner rationale) with filtering, sorting and a settled-total row.
- Render:
render.yamldeploys the full Express server in one click, with PayPal sandbox keys as environment variables.
How we built it
Node and Express, PayPal REST (Vault v3, Orders v2), the Anthropic SDK, a JSON-file wallet and ledger, a zero-build dashboard with AG Grid, and a demo coding agent that runs two jobs: a small one it pays for on its own, and a big one that needs your approval.
Challenges we ran into
Keeping the human in control without killing autonomy: the mandate is enforced in code after the model runs, and over-limit purchases wait for a human with a timeout. Idempotency on agent-initiated charges so retries never double-bill.
Accomplishments that we're proud of
An agent that really is the payer: it hits a 402, decides, pays from a saved PayPal wallet inside its limits, and hands anything bigger to a human, all in one flow you can watch on the dashboard and ledger.
What we learned
PayPal Vault plus stored-credential Orders is a clean rail for agent payments, and putting hard limits in code rather than in the prompt is what makes autonomous spending something people can trust.
What's next for ContextPay
Per-tool mandates, spend analytics, and live compression billing so the credits are real rather than simulated.
Built during the hackathon
ContextPay was built new during the submission period (started Oct 7, 2026). It calls an existing context-compression API through its public API. Everything in the repo is new for this hackathon: the PayPal payment layer, the Claude planner, the mandate engine, the dashboard and ledger, and the demo agent.
Built With
- ag-grid
- anthropic
- claude
- express.js
- github
- javascript
- node.js
- paypal
- paypal-orders-api
- paypal-vault
- render
- zod
Log in or sign up for Devpost to join the conversation.