Skip to main content

FiGuard pre-flight spend authorization for LangChain agents

Project description

figuard-langchain

Pre-flight spend authorization for LangChain agents. One line to add budget enforcement and velocity controls to any AgentExecutor.

pip install figuard-langchain

Quick start

from figuard_langchain import auto_guard_langchain

# Monetary budget — enforces dollar spend on tools with an "amount" parameter
executor = auto_guard_langchain(executor, budget=500)

# Velocity control — catches runaway loops even when tools have no dollar amount
executor = auto_guard_langchain(executor, budget=500, velocity_max_per_minute=10)

result = executor.invoke({"input": "Book a flight to NYC"})

auto_guard_langchain creates a FiGuard budget, wires a callback handler to the executor, and returns the same executor ready to run. Uses the shared public sandbox by default — no account required.

What gets enforced

Scenario How to enforce
Tools with dollar amounts (price, cost, amount fields) budget=500 — denies when total spend exceeds $500
Research agents, code agents, any tool without a financial parameter velocity_max_per_minute=10 — denies the 11th call in 60 seconds
Both Pass both params — monetary ceiling + loop detection

OTEL / Langfuse integration

FiGuard emits authorization spans to any OpenTelemetry backend automatically when one is configured. With Langfuse:

from langfuse import Langfuse
from figuard_langchain import auto_guard_langchain

lf = Langfuse(public_key="...", host="https://us.cloud.langfuse.com")
executor = auto_guard_langchain(executor, budget=500, velocity_max_per_minute=10)

Every authorize() call appears as a GUARDRAIL span in the Langfuse trace. Denied calls appear as ERROR spans — visible in the execution graph without any extra configuration.

Full control

For advanced fleet patterns, delegation tokens, or per-category allocations, use the main figuard package directly:

pip install figuard[langchain]
from figuard import FiGuardClient
from figuard.integrations.langchain import FiGuardCallbackHandler

client = FiGuardClient()
budget = client.create_budget(
    user_id="alice",
    total_limit=500.00,
    currency="USD",
    velocity_max_per_minute=10,
    allocations=[
        {"category": "flights", "limit": 300.00, "mode": "CATEGORY_CONSTRAINED"},
        {"category": "hotels",  "limit": 200.00, "mode": "CATEGORY_CONSTRAINED"},
    ],
)
handler = FiGuardCallbackHandler(
    client=client,
    session_token=budget.primary_token.session_token,
)
executor.callbacks = [handler]

Self-hosting

git clone https://github.com/figuard/figuard-core
cd figuard-core
docker compose up -d

Set FIGUARD_BASE_URL=http://localhost:8080 and FIGUARD_API_KEY=<your-key> before running your agent.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

figuard_langchain-1.1.2.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

figuard_langchain-1.1.2-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file figuard_langchain-1.1.2.tar.gz.

File metadata

  • Download URL: figuard_langchain-1.1.2.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for figuard_langchain-1.1.2.tar.gz
Algorithm Hash digest
SHA256 5ab8a3775d62bbc24bb4e1e2d945412dd3ef1347a6c7f9d8632417c1246c671d
MD5 32a5017dea4d8ef7820f7e5ae38e38c6
BLAKE2b-256 8a08c9a3f3cbf058245f2ec94ee788168c3e5075385b83ba297fef1e247c4c41

See more details on using hashes here.

Provenance

The following attestation bundles were made for figuard_langchain-1.1.2.tar.gz:

Publisher: publish-python.yml on figuard/figuard-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file figuard_langchain-1.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for figuard_langchain-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f631025e303f4a2293fdd5a770f5deb498a7fc40940e9660c36589892e58c7ba
MD5 a988aadb391857d6b1265204bd55e008
BLAKE2b-256 3c8e029ab13c288f0bb4eef10052049ab3962a05d23cc0cda33f55adde7a6fb1

See more details on using hashes here.

Provenance

The following attestation bundles were made for figuard_langchain-1.1.2-py3-none-any.whl:

Publisher: publish-python.yml on figuard/figuard-core

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page