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
Release files for figuard-langchain 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| figuard_langchain-1.2.0.tar.gz | 2.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| figuard_langchain-1.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.0 kB
Release files / figuard_langchain-1.2.0.tar.gz
| Download URL | figuard_langchain-1.2.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ac8a065e52133e8c55938b325cbf4cbc4fbddb862ef3d6674b5fd70334a3618f
|
|
BLAKE2b-256 checksum How to use checksums |
d1cb31ab094ddf5cd5378ec80014c8c9902310607542ce61ef706d1dd082b6f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 16, 2026.
Transparency logRelease files / figuard_langchain-1.2.0-py3-none-any.whl
| Download URL | figuard_langchain-1.2.0-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c4cd3600f235426be7b1efc3c28b020ee567039cddba32fa12d49fa628b8a13
|
|
BLAKE2b-256 checksum How to use checksums |
074ba2f9fcdb9b1931cf8fca7172e506808f026502f6e1ef3f314811dd747ddc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 16, 2026.
Transparency log