Vaultak runtime security callback handler for LangChain agents
Project description
langchain-vaultak
Runtime security for LangChain agents, powered by Vaultak.
Intercept every agent action, score risk in real time, enforce policies, and automatically block dangerous behavior before it reaches your production systems — with two lines of code.
The Problem
LangChain agents can write to databases, send emails, execute code, and call external APIs. Without a security layer, a single misconfigured tool call can cause real damage — deleted records, leaked PII, unauthorized transactions.
langchain-vaultak wraps your existing LangChain agents with Vaultak's runtime security engine. Every tool call and agent action is scored and checked against your policy rules before it executes.
Install
pip install langchain-vaultak
Requires Python 3.8+, langchain-core>=0.1.0, and a Vaultak account at vaultak.com.
Quick Start
from langchain_vaultak import VaultakCallbackHandler
# Initialize with your Vaultak API key
handler = VaultakCallbackHandler(api_key="vtk_...")
# Pass as a callback to any LangChain agent
result = agent.run("Summarize our Q3 sales data", callbacks=[handler])
That is all. Every action the agent takes is now monitored, scored, and checked against your Vaultak policy rules.
What It Does
| Event | Vaultak Action |
|---|---|
| Agent picks a tool | Risk-scores the action (0–10) |
| Tool call starts | Checks against policy rules |
| Tool call returns output | Scans output for PII and masks it |
| Tool or LLM error | Sends alert to your Vaultak dashboard |
| Chain error | Triggers automatic rollback |
| Risk score ≥ threshold | Blocks the action, raises exception |
Configuration
handler = VaultakCallbackHandler(
api_key="vtk_...", # Required — your Vaultak API key
agent_name="sales-agent", # Label for this agent in the dashboard
block_on_high_risk=True, # Block actions that exceed the threshold
risk_threshold=7.0, # 0–10 scale — default 7.0
verbose=True, # Log all scored actions
)
Setting a lower threshold for sensitive workloads
# For agents with access to production databases or financial systems
handler = VaultakCallbackHandler(
api_key="vtk_...",
agent_name="prod-db-agent",
risk_threshold=5.0, # More conservative
)
Using with Different Agent Types
ReAct / AgentExecutor
from langchain.agents import AgentExecutor
from langchain_vaultak import VaultakCallbackHandler
handler = VaultakCallbackHandler(api_key="vtk_...")
agent_executor = AgentExecutor(agent=agent, tools=tools)
result = agent_executor.invoke(
{"input": "your task"},
config={"callbacks": [handler]}
)
LCEL (LangChain Expression Language)
from langchain_vaultak import VaultakCallbackHandler
handler = VaultakCallbackHandler(api_key="vtk_...")
chain = prompt | llm | output_parser
result = chain.invoke(
{"input": "your task"},
config={"callbacks": [handler]}
)
Global callback (applies to all chains)
from langchain.callbacks import set_handler
from langchain_vaultak import VaultakCallbackHandler
set_handler(VaultakCallbackHandler(api_key="vtk_..."))
Viewing Results
Every action scored by this handler appears in your Vaultak dashboard at app.vaultak.com. You can:
- See real-time risk scores for every tool call
- Review the full action history for any agent run
- Configure or tighten policy rules without code changes
- Set up alerts for high-risk events
Requirements
- Python 3.8+
langchain-core >= 0.1.0vaultak >= 0.1.0- A Vaultak account — sign up at vaultak.com
Links
- Vaultak docs: docs.vaultak.com
- LangChain docs: python.langchain.com
- Issues: github.com/vaultak/langchain-vaultak/issues
License
MIT — see LICENSE
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 langchain_vaultak-0.1.0.tar.gz.
File metadata
- Download URL: langchain_vaultak-0.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
038edd79ec26cf87b1705940cd779aaa843dba9df22315c7f425ba40b11b683c
|
|
| MD5 |
d7f376423d8328afee9e429b3f70e072
|
|
| BLAKE2b-256 |
b13ba0174bc773650e27e1b1799598664b02e0bd90bbf0a1f0b6360276f564d6
|
File details
Details for the file langchain_vaultak-0.1.0-py3-none-any.whl.
File metadata
- Download URL: langchain_vaultak-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f43ec4be9b7e24edfa0e903b88ac4bab1f75cba1d44f86a9c230f5c388c6f59d
|
|
| MD5 |
4da37d63f03346ca4054d12f2cdc8740
|
|
| BLAKE2b-256 |
c19ddfeaaefb253a72b22b133a7a5e1a09db56d58084b44461dbe1017f967838
|