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.2.0.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.2.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: figuard_langchain-1.2.0.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.2.0.tar.gz
Algorithm Hash digest
SHA256 ac8a065e52133e8c55938b325cbf4cbc4fbddb862ef3d6674b5fd70334a3618f
MD5 47f4adaa46e81ede0541f1bd5f8b33ce
BLAKE2b-256 d1cb31ab094ddf5cd5378ec80014c8c9902310607542ce61ef706d1dd082b6f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for figuard_langchain-1.2.0.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.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for figuard_langchain-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c4cd3600f235426be7b1efc3c28b020ee567039cddba32fa12d49fa628b8a13
MD5 a8882530d2ee48e7ea96ff86298962f0
BLAKE2b-256 074ba2f9fcdb9b1931cf8fca7172e506808f026502f6e1ef3f314811dd747ddc

See more details on using hashes here.

Provenance

The following attestation bundles were made for figuard_langchain-1.2.0-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