Inspiration

Freelancers and small service firms lose hours writing quotes for "one more thing" and chasing payment for extras. Meanwhile their clients are starting to delegate purchasing to AI assistants. A client's agent can already buy a product from a catalog, but it cannot contract custom work whose scope and price change. Two questions stay unanswered: "is this already included in what I paid for?" and "what does the extra cost, and why?"

What it does

DealingWith Agent answers both, for a person on the web and for the client's own AI agent over MCP.

  • The client asks for a change. An AI agent reads the request against the contracted scope and says what is already included (US$0.00), what is extra, and why. Every line cites the contract clause or the pricing rule behind it.
  • Code sets the price, never the model. A deterministic engine prices each extra from the provider's own catalog, in integer cents.
  • PayPal collects. A person pays on PayPal's approval page. The client's agent can pay on its own, but only inside a budget the client authorized once with PayPal, with a per-purchase and a total limit. Above the limit, the agent gets an approval link for a human.
  • The project updates itself. Paid extras become new scope clauses, so the next request that matches one comes back included at US$0.00.
  • The provider sees the money. An AG Studio dashboard shows revenue, the pipeline, unpaid additionals and the agent channel. Its assistant drafts payment reminders whose amounts come from the data, not from the model.

How we built it

  • PayPal Orders v2: pay-now orders (intent CAPTURE) and the one-time funding of an agent's budget (intent AUTHORIZE).
  • PayPal Payments v2: each purchase the agent makes is a partial capture of that authorization (final_capture: false), checked against the mandate's limits under a row lock.
  • PayPal Webhooks: six event types, signature-verified with PayPal and applied once per event id. Every PayPal call carries a PayPal-Request-Id derived from the quote id and version, so a retry or a double click never pays twice.
  • Quoting agent: Claude Opus 5.5 (OpenAI gpt-6.1-sol passes with the same prompts) returns structured intents validated with Zod. It never returns an amount.
  • MCP server: nine tools over Streamable HTTP with a per-agent token, so Claude, Claude Code or Cursor can request quotes and pay within the mandate.
  • Dashboard: AG Studio on AG Grid, with three custom widgets and an assistant on Claude Sonnet 5.5 through our own backend adapter.
  • Stack: TypeScript monorepo, Hono on Node 22, Drizzle on Postgres, React 19 with Vite, Vitest. Hosted on Render, deployed only after CI passes.

Challenges we ran into

  • Letting an agent spend money safely. The agent may only spend inside limits the client set once. We reserve the spend under a database lock before capturing, so two agent calls at once cannot pass the limit together.
  • Keeping the model away from prices. The model only classifies and cites; amounts come from code. The same rule holds in the dashboard assistant, where wording that contains an amount is refused.
  • Exactly-once payments. The browser return and the webhook can arrive in any order and more than once. Both reach the same state, and a duplicate never creates a second payment or a second scope clause.

Accomplishments that we're proud of

  • A client's own AI agent contracts and pays for custom work end to end, inside a budget authorized once with PayPal.
  • The same versioned quote serves the web and MCP: a quote requested by an agent is the same quote id and version a human sees.
  • 534 automated tests with no credentials, and a live eval where Claude and OpenAI both classify the five demo requests correctly.

What we learned

PayPal's authorization plus partial captures is a natural fit for agent spending: the client approves once on PayPal's page, and every purchase the agent makes is a capture against that approval, with no new prompt for the client.

What's next

PayPal Vault for standing mandates that do not expire after 29 days, OAuth for MCP instead of tokens, and more than one provider per deployment.

Best Use of AG Grid

The provider's home in DealingWith Agent is an AG Studio report (ag-studio-react 3.1.0 on AG Grid 36.3.0) built on our own API: quotes, quote lines, payments, requests and the mandate that limits what a client's AI agent may spend.

Custom widgets. Three widgets registered with createWidgets, each with a data mapping and style controls in Studio's editor: a quotes table with AG Grid inside (status and channel pills, a pinned total, cross-filtering both ways with Studio's charts), an agent budget meter that shows what the client's AI agent may still spend, and KPI tiles whose count line follows the data. Each declares a formatShape, so Studio's own AI agents can restyle it.

Theming and layout. Studio wears the product's design tokens: the Geist typeface, a pine accent and a six-colour chart palette with at least 3:1 contrast. The report opens in read mode on three pages (Overview, Collections, Agent channel) and re-flows to two columns on tablets and one on phones.

Studio Agent Framework. Studio's built-in agents run on Claude Sonnet 5.5 through our own LLM adapter: the browser streams each turn to our backend, so the API key never reaches the browser. Next to them we added a custom Collections agent that Studio's lead agent delegates to. It finds unpaid additionals and drafts a payment reminder whose amounts and total are rendered by code from the quote data, never written by the model. We also wrapped the Widget agent's configure_widget tool so a restyle keeps the titles and settings it leaves out.

Code: https://github.com/Walter102202/dealingwith-agent/tree/main/apps/web/src/dashboard

Built With

Share this project:

Updates

Submission history