paybondpaybond
Sign in

Recipe · Framework

Spend controls for LangGraph ToolNode calls

spend verify via awrapToolCall before ToolNode runs, auto-evidence after success, and policy budgets for LangGraph — TypeScript and Python.

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

You'll build

LangGraph nodes that refuse unpaid side effects without Harbor approval

LangGraph executes tools through ToolNode. Paybond hooks that boundary with awrapToolCall — spend verify before side-effecting tools execute, then auto-evidence after success. Model inference stays on your provider client.

Adapter reference: /docs/kit/langgraph.

  • awrapToolCall before ToolNode

    Harbor authorize runs before side-effecting tools execute in your StateGraph.

  • Auto-evidence

    Hooks finalize spend and submit signed evidence after paid tool success.

  • Policy budgets

    Versioned YAML caps per-call and intent spend for long-lived graphs.

  • TypeScript and Python

    Same langgraph adapter on npm and pip (paybond-kit[langgraph]).

Why Paybond (not just LangGraph checks)?

LangGraph tool nodes and host 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).

LangGraph alone versus Paybond Harbor spend controls
  • Model / input guardrails

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

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

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

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

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

How it works

Paybond hooks ToolNode via awrapToolCall: Harbor authorize before the tool runs, then auto-evidence after success.

Adapter flow

  1. ToolNode

    LangGraph invokes a side-effecting tool

  2. Paybond awrapToolCall

    Harbor authorize before your tool runs

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

    Your tool body performs the paid work

  4. Evidence

    Hook finalizes spend + auto-evidence

Paybond hooks ToolNode via awrapToolCall: Harbor authorize before the tool runs, then auto-evidence after success.

3-minute quickstart

Smoke the langgraph adapter sandbox contract:

terminal

TS
Terminal commandSwipe to inspect long lines
paybond login
paybond agent demo langgraph 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 LangGraph 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 langgraph --out paybond-langgraph.ts
paybond policy init --preset travel --out paybond.policy.yaml

Or the full wizard:

Terminal
Terminal commandSwipe to inspect long lines
paybond init --solution travel --max-spend-usd 500 --framework langgraph --non-interactive

Wire middleware

Recommended wiring

paybond.agent with framework langgraph returns awrapToolCall and createToolNode for your StateGraph.

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 { awrapToolCall, createToolNode } = await paybond.agent({
  policy: "travel",
  framework: "langgraph",
  tools: [bookHotelTool, searchWebTool],
});

const node = createToolNode!([bookHotelTool, searchWebTool], { awrapToolCall });
// Add node to your StateGraph

Install extras: pip install "paybond-kit[langgraph]".

Manual hook wiring

When you already bound a PaybondAgentRun:

paybond_session.py

PY
Python code sampleSwipe to inspect long lines
from langgraph.prebuilt import ToolNode
from paybond_kit.langgraph_hooks import paybond_awrap_tool_call

node = ToolNode(tools, awrap_tool_call=paybond_awrap_tool_call(run))

paybond-session.ts

TS
TypeScript code sampleSwipe to inspect long lines
import { paybondAwrapToolCall, paybondToolNode } from "@paybond/kit/langgraph";

const node = paybondToolNode(tools, run);

Approval holds: when Paybond returns an approval hold, surface it to operators, approve in the tenant console, then retry with the same operation, amount, metadata, and approvalToken. Hard denials must not execute the tool.

Production checklist

Production checklist for Paybond-guarded LangGraph tools.

Production checklist

Works with

Works with

  • LangGraph
  • OpenAI
  • Anthropic
  • MCP

Ready to test?

Developer reference: /docs/kit/langgraph.