Skip to main content

Vaultak runtime security callback handler for LangChain agents

Project description

langchain-vaultak

PyPI version License: MIT Python 3.8+

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.0
  • vaultak >= 0.1.0
  • A Vaultak account — sign up at vaultak.com

Links


License

MIT — see LICENSE

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

langchain_vaultak-0.1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_vaultak-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

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

Hashes for langchain_vaultak-0.1.0.tar.gz
Algorithm Hash digest
SHA256 038edd79ec26cf87b1705940cd779aaa843dba9df22315c7f425ba40b11b683c
MD5 d7f376423d8328afee9e429b3f70e072
BLAKE2b-256 b13ba0174bc773650e27e1b1799598664b02e0bd90bbf0a1f0b6360276f564d6

See more details on using hashes here.

File details

Details for the file langchain_vaultak-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_vaultak-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f43ec4be9b7e24edfa0e903b88ac4bab1f75cba1d44f86a9c230f5c388c6f59d
MD5 4da37d63f03346ca4054d12f2cdc8740
BLAKE2b-256 c19ddfeaaefb253a72b22b133a7a5e1a09db56d58084b44461dbe1017f967838

See more details on using hashes here.

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