paybondpaybond
Sign in

Recipe · Framework

Spend controls for CrewAI tools

spend verify before @tool / BaseTool handlers run, auto-evidence after success, and policy budgets for CrewAI — Python.

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

You'll build

CrewAI tools that bind procurement spend to Paybond capabilities

CrewAI agents call tools through @tool decorators and BaseTool subclasses. Paybond hooks that execution boundary — spend verify before side-effecting tools execute, then auto-evidence after success. Model inference stays on your provider client.

Python only — install paybond-kit[crewai] for the native adapter.

Adapter reference: /docs/kit/crewai.

  • spend verify before @tool

    Wrapped @tool / BaseTool handlers authorize operation and amount before paid work.

  • Auto-evidence

    Guarded tools finalize spend and submit signed evidence after success.

  • Policy budgets

    Versioned YAML caps per-call and intent spend for procurement crews.

  • Python native

    Install paybond-kit[crewai] — TypeScript stacks use agent-agnostic or another adapter.

Why Paybond (not just CrewAI checks)?

CrewAI tool wrappers 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).

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

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

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

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

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

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

How it works

Paybond wraps CrewAI @tool / BaseTool handlers: Harbor authorize before the tool runs, then auto-evidence after success.

Adapter flow

  1. @tool / BaseTool

    CrewAI agent invokes a side-effecting tool

  2. Paybond wrap

    Harbor authorize before your handler runs

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

    Your tool body performs the paid work

  4. Evidence

    Wrapped tool finalizes spend + auto-evidence

Paybond wraps CrewAI @tool / BaseTool handlers: Harbor authorize before the tool runs, then auto-evidence after success.

3-minute quickstart

Smoke the crewai adapter sandbox contract:

Terminal
Terminal commandSwipe to inspect long lines
paybond login
paybond agent demo crewai smoke \
  --operation procurement.submit_po \
  --requested-spend-cents 12000 \
  --evidence-preset cost_and_completion \
  --format table

Install the extra first:

Terminal
Terminal commandSwipe to inspect long lines
pip install "paybond-kit[crewai]"

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 CrewAI tool call: approved spend, requested amount, and verified cost_and_completion evidence.

What success looks like

Authorized tool call · illustrative

Sandbox path
Operation
procurement.submit_po
Status
Approved
Requested
$120.00
Evidence
Verified
Preset
cost_and_completion

Scaffold

Terminal
Terminal commandSwipe to inspect long lines
paybond init agent-middleware --framework crewai --out paybond_crewai.py
paybond policy init --preset saas --out paybond.policy.yaml

Or the vertical template:

Terminal
Terminal commandSwipe to inspect long lines
paybond init --template crewai-procurement-agent --framework crewai

Clone-and-run GitHub starter:

Terminal
Terminal commandSwipe to inspect long lines
git clone https://github.com/nonameuserd/paybond-crewai-procurement-agent.git
cd paybond-crewai-procurement-agent
cp .env.example .env.local
paybond-kit-login
pip install -r requirements.txt
python app.py

Wire middleware

Recommended wiring

paybond.agent with framework crewai returns guarded agent_tools for your CrewAI agents.

paybond_session.py

PY
Python code sampleSwipe to inspect long lines
from crewai.tools import tool
from paybond_kit import Paybond
from paybond_kit.agent.registry import create_paybond_tool_registry
from paybond_kit.crewai import create_paybond_crewai_config

# Price lives in your catalog (or ERP) — not in an LLM-invented amount_cents.
CATALOG = {"LAP-14": {"vendor_id": "vendor-acme", "unit_cents": 12_000}}

@tool("procurement.submit_po")
def submit_po(sku: str, quantity: int = 1) -> str:
    """Submit a purchase order. Unit price comes from the catalog."""
    item = CATALOG[sku]
    cost_cents = item["unit_cents"] * quantity
    return json.dumps(
        {
            "status": "completed",
            "sku": sku,
            "vendor_id": item["vendor_id"],
            "cost_cents": cost_cents,
        }
    )

paybond = await Paybond.open(api_key=os.environ["PAYBOND_API_KEY"])
run = await paybond.agent_run.bind(
    {
        "bootstrap": {
            "kind": "sandbox",
            "operation": "procurement.submit_po",
            "requested_spend_cents": 12_000,
            "completion_preset": "cost_and_completion",
        },
        "registry": create_paybond_tool_registry(
            {
                "default_deny": True,
                "side_effecting": {
                    "procurement.submit_po": {
                        "operation": "procurement.submit_po",
                        "evidence_preset": "cost_and_completion",
                        "spend_cents": lambda args: CATALOG[args["sku"]]["unit_cents"]
                        * int(args.get("quantity", 1)),
                    }
                },
            }
        ),
    }
)
guarded_tools = create_paybond_crewai_config(run, [submit_po, search_catalog]).tools
# Register guarded_tools on your CrewAI agents.

Manual hook wiring

When you already bound a PaybondAgentRun:

paybond_session.py

PY
Python code sampleSwipe to inspect long lines
from paybond_kit.crewai import create_paybond_crewai_config

config = create_paybond_crewai_config(run, tools)
guarded_tools = config.tools
# Or wrap incrementally: config.wrap_tool(new_tool)

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 CrewAI tools.

Production checklist

Works with

Works with

  • CrewAI
  • OpenAI
  • Anthropic
  • MCP

Ready to test?

Developer reference: /docs/kit/crewai.

Public template: paybond-crewai-procurement-agent.