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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ab8a3775d62bbc24bb4e1e2d945412dd3ef1347a6c7f9d8632417c1246c671d
|
|
| MD5 |
32a5017dea4d8ef7820f7e5ae38e38c6
|
|
| BLAKE2b-256 |
8a08c9a3f3cbf058245f2ec94ee788168c3e5075385b83ba297fef1e247c4c41
|
Provenance
The following attestation bundles were made for figuard_langchain-1.1.2.tar.gz:
Publisher:
publish-python.yml on figuard/figuard-core
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
figuard_langchain-1.1.2.tar.gz -
Subject digest:
5ab8a3775d62bbc24bb4e1e2d945412dd3ef1347a6c7f9d8632417c1246c671d - Sigstore transparency entry: 1776706591
- Sigstore integration time:
-
Permalink:
figuard/figuard-core@34f084eae4450e6743f2697f1e88669f0495b3b0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/figuard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@34f084eae4450e6743f2697f1e88669f0495b3b0 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file figuard_langchain-1.1.2-py3-none-any.whl.
File metadata
- Download URL: figuard_langchain-1.1.2-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f631025e303f4a2293fdd5a770f5deb498a7fc40940e9660c36589892e58c7ba
|
|
| MD5 |
a988aadb391857d6b1265204bd55e008
|
|
| BLAKE2b-256 |
3c8e029ab13c288f0bb4eef10052049ab3962a05d23cc0cda33f55adde7a6fb1
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
figuard_langchain-1.1.2-py3-none-any.whl -
Subject digest:
f631025e303f4a2293fdd5a770f5deb498a7fc40940e9660c36589892e58c7ba - Sigstore transparency entry: 1776706818
- Sigstore integration time:
-
Permalink:
figuard/figuard-core@34f084eae4450e6743f2697f1e88669f0495b3b0 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/figuard
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@34f084eae4450e6743f2697f1e88669f0495b3b0 -
Trigger Event:
workflow_dispatch
-
Statement type: