langchain-tollwarden
TollWarden payment security for LangChain / LangGraph agents — agents inherit "scan before you pay" by default.
pip install langchain-tollwarden
Two lines
from tollwarden import TollWardenClient
from langchain_tollwarden import TollWardenProvenanceCallback, tollwarden_tools
tollwarden = TollWardenClient(agent_id="my-agent") # free API key auto-minted (100 free scans)
tools = [*tollwarden_tools(tollwarden), *your_other_tools]
callbacks = [TollWardenProvenanceCallback(tollwarden)] # ← the important line
# pass tools= and callbacks= to your agent/executor as usual
Every x402 payment your agent scans gets an allow / flag / block verdict with machine-readable reasons: prompt-injection-triggered payments, replayed nonces, overpayment vs the quote, secrets/PII leaking in payment metadata, lookalike-token contracts, address poisoning, counterparty reputation.
Why the callback is the important line
TollWarden's strongest detector catches payments whose decision came from content the agent just read — a prompt-injected page or tool result that says "send payment to 0x…". That check needs to know what the agent read. TollWardenProvenanceCallback observes every tool output and retrieval automatically, so the very next scan is provenance-tagged and the injection check runs with real input. No prompt engineering, no developer learning what "provenance" means — it's just on. (TollWarden's own tool outputs are excluded, so verdicts never pollute the signal.)
Enforcement: payments that can't execute when blocked
Tools + descriptions rely on the model choosing to scan. guarded_payment doesn't:
from langchain_tollwarden import guarded_payment
safe_pay = guarded_payment(execute_x402_payment, tollwarden) # strict=True to refuse flags too
# build your payment tool from safe_pay — on a block verdict it raises
# TollWardenBlockedError BEFORE execute_x402_payment is ever invoked.
For wallet-level enforcement (the signer itself refuses unscanned payments), see TollWardenEnforcer in the tollwarden SDK.
The toolset
| Tool | When the agent is told to use it |
|---|---|
tollwarden_scan_payment |
ALWAYS, immediately before settling any x402 payment (or before paying a received 402 offer with direction="incoming") |
tollwarden_check_reputation |
Before dealing with an unfamiliar counterparty address |
tollwarden_report_counterparty |
After a bad payment experience (always free) — warns other agents |
Verdicts are Ed25519-signed and payment-bound; the underlying client verifies them against a pinned key automatically.
MIT. TollWarden is advisory and non-custodial: it never touches keys, wallets, or funds.
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 langchain_tollwarden-0.1.0.tar.gz.
File metadata
- Download URL: langchain_tollwarden-0.1.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bde2b9907901238bee072eb94019e70eac9d8727106d3d2a30b0964eb30f138c
|
|
| MD5 |
94dab90925f6c6ea0053160d8e14c3d1
|
|
| BLAKE2b-256 |
a4f87389262921960782f0e441c73b4be85bc91b02dea612a831f4ac3bb96b91
|
File details
Details for the file langchain_tollwarden-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_tollwarden-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
be3161c5987a98fbbc52bb8e4493837a933a63964ba2cf0848d9124e8d94e24f
|
|
| MD5 |
972a5584259b736dd3c8ed90d461d48f
|
|
| BLAKE2b-256 |
3aa80d5e3ac3ba03276bc870f4836bb741efba12371d3910f7c38cd67ba220ad
|