paybondpaybond
Sign in

Recipe · Spend controls

Spend controls for any agent tool surface

spend verify before { name, execute } tools run, auto-evidence after success — Claude tool-use, Gemini, queue workers, and custom orchestrators.

  1. 1Wire
  2. 2Authorize
  3. 3Smoke

You'll build

Framework-agnostic middleware smoke with Harbor authorize + evidence

Paybond's recommended default when you have no agent framework SDK — or when you call Claude/Gemini tool-use, a queue worker, or a custom orchestrator directly. One paybond.instrument() call wraps { name, execute } tools with spend verify before side effects and auto-evidence after success.

Adapter reference: /docs/kit/agent-agnostic.

  • Any { name, execute } surface

    Wrap Claude tool-use, Gemini function calls, queue workers, or custom orchestrators.

  • spend verify before execute

    createPaybondGenericAgentConfig authorizes operation and amount before side effects.

  • Auto-evidence

    Wrapped execute finalizes spend and submits signed evidence after tool success.

  • TypeScript and Python

    Same generic path via paybond.instrument() / paybond.agent() on npm and pip.

Why Paybond (not just custom checks)?

Host or model approvals do not enforce a spend limit, a per-operation permission check (capability token), or a signed completion receipt tied to a spend agreement (intent).

Custom agent runtime alone versus Paybond Harbor spend controls
  • Model / input guardrails

    Custom runtime alone
    Yes — SDK or host checks and approvals
    With Paybond
    Yes — plus Harbor authorize at the tool boundary
  • Spend boundary

    Custom runtime alone
    No per-tool Harbor budget or capability token
    With Paybond
    Per-call and intent budgets enforced before invoke
  • Signed evidence

    Custom runtime alone
    SDK traces / logs only
    With Paybond
    Signed completion digests bound to the intent
  • Intent binding

    Custom runtime alone
    No Harbor intent or settlement receipt
    With Paybond
    Capability token + intentId from authenticated bind
  • Paid tool deny / HITL

    Custom runtime alone
    Host or SDK approvals only
    With Paybond
    spend verify, deny, or HITL hold before side effects

How it works

Paybond wraps generic { name, execute } tools: Harbor authorize before execute, then auto-evidence after success.

Adapter flow

  1. Orchestrator tool call

    Your runtime invokes a registered { name, execute } tool

  2. Paybond wrap

    Harbor authorize before your handler runs

    • Verify spend and operation
    • Deny or HITL hold
    • Issue / check capability
  3. Execute

    Your handler performs the paid work

  4. Evidence

    Wrapped execute finalizes spend + auto-evidence

Paybond wraps generic { name, execute } tools: Harbor authorize before execute, then auto-evidence after success.

3-minute quickstart

Smoke the generic adapter sandbox contract:

terminal

TS
Terminal commandSwipe to inspect long lines
paybond login
paybond agent demo generic smoke \
  --operation paid-tool \
  --requested-spend-cents 100 \
  --evidence-preset cost_and_completion \
  --format table

When the smoke succeeds you should see:

  • ✓ Spend approved
  • ✓ Tool completed
  • ✓ Evidence verified (cost_and_completion)

What success looks like

Example status after a Paybond-guarded agent-agnostic tool call: approved spend, requested amount, and verified cost_and_completion evidence.

What success looks like

Authorized tool call · illustrative

Sandbox path
Operation
paid-tool
Status
Approved
Requested
$1.00
Evidence
Verified
Preset
cost_and_completion

Scaffold

Terminal
Terminal commandSwipe to inspect long lines
paybond init agent-middleware --framework generic --out paybond-agent.ts
paybond policy init --preset travel --out paybond.policy.yaml

Validate before deploy:

Terminal
Terminal commandSwipe to inspect long lines
paybond policy validate-tools --file paybond.policy.yaml --local-only

Wire middleware

Recommended wiring

paybond.agent without a framework SDK returns tools with PaybondGenericToolCall envelopes so Harbor runs before execute.

paybond-session.ts

TS
Code exampleSwipe to inspect long lines
import { Paybond } from "@paybond/kit";

const paybond = await Paybond.open({ apiKey: process.env.PAYBOND_API_KEY! });

const { tools, run } = await paybond.agent({
  policy: "travel",
  tools: {
    "travel.book_hotel": bookHotel,
    searchWeb: searchWeb,
  },
});

// Your orchestrator calls tools with PaybondGenericToolCall envelopes:
const bookHotelTool = tools.find((t) => t.name === "travel.book_hotel")!;
const result = await bookHotelTool.execute({
  toolName: "travel.book_hotel",
  toolCallId: "call-1",
  arguments: { city: "Lisbon", estimatedPriceCents: 18_700 },
});

Claude / Gemini tool-use without a framework SDK

Map model function calls to Paybond-wrapped handlers:

  1. Parse the model's tool call (name, arguments, and call id).
  2. Find the matching entry in instrumented.tools.
  3. Call execute with the Paybond envelope — authorization and evidence run automatically.

For the Claude Agent SDK specifically, use the Claude Agents adapter guide.

Production: omit sandbox defaults, use deferred bind, then instrumented.bind({ intentId, capabilityToken }) per session. Lazy binding: pass context: () => activeRequest.paybond on instrument().

Production checklist

Production checklist for Paybond agent-agnostic spend controls.

Production checklist

Works with

Works with

  • Agent-agnostic
  • OpenAI
  • Anthropic
  • Gemini

Ready to test?

Developer reference: /docs/kit/agent-agnostic.