LangChain.

Check every query of a LangChain agent before it reaches the database, in Python and JavaScript: a check-only tool and a guarded SQLDatabase, offline or online.

Available. Python: langchain-vericto 0.1.0 on PyPI (code, Apache-2.0). JavaScript: @vericto/sdk/langchain, in @vericto/sdk 0.6.0 (Apache-2.0). Vericto is listed in the LangChain docs: for Python, in the Database tools table and in the providers list; for JavaScript, in the tools index and in the providers list.

Overview

Vericto checks every SQL statement a LangChain agent writes before it reaches the database: it parses it into a syntax tree and evaluates it against deterministic rules (for example VERICTO-001, a DELETE without WHERE). A blocked statement is not executed, and the model gets the rule and the suggested fix to try again.

  • A check-only tool: VerictoSQLCheck (Python) and VerictoCheckSqlTool (JavaScript) return the verdict and run nothing.
  • A guarded database: VerictoSQLDatabase (Python) and VerictoSqlDatabase (JavaScript) are a LangChain SQLDatabase that checks every statement, including the ones the SQL toolkit generates.
  • Six dialects: PostgreSQL, MySQL, Oracle, SQL Server, Snowflake and SQLite.

Offline or online

Offline (Python and JavaScript): the local engine of the Vericto CLI 2.1.0 or later (2.4.0 is current), with no account and no network; the SQL never leaves the machine. Turn it on with offline=True in Python, new Vericto({ offline: true }) in JavaScript, or VERICTO_OFFLINE=1 in both. It checks the standard rules at their default severities, like the offline CLI with --sql: a DROP TABLE is blocked.

Online (Python and JavaScript): your workspace's rules through the Runtime API, with masked sensitive columns, agent allowlists and the audit trail. It needs VERICTO_API_KEY (scope proxy:evaluate) and VERICTO_DATABASE_ID, the database registered in the dashboard.

In JavaScript, the SDK looks for the CLI in VERICTO_CLI, then in the @vericto/vericto-cli in your node_modules, then on PATH; it never downloads anything. Offline together with an API key is a configuration error (VerictoConfigError, OFFLINE_CONFLICT): choose one mode.

Python: langchain-vericto

Install the package; the sql extra adds VerictoSQLDatabase (with langchain-community and SQLAlchemy). Python 3.11 or later.

pip install -U "langchain-vericto[sql]"     # or: uv add "langchain-vericto[sql]"

# Offline mode: the Vericto CLI, 2.1.0 or later (2.4.0 is current)
npm i -g @vericto/vericto-cli                # or: brew install vericto/tap/vericto
export VERICTO_OFFLINE=1                     # or offline=True in code

# Online mode: your workspace
export VERICTO_API_KEY=vtro_...              # scope proxy:evaluate
export VERICTO_DATABASE_ID=<database-id>     # the database in the dashboard

Check a query: VerictoSQLCheck

The tool takes query, the exact SQL, and an optional dialect. It returns the verdict as JSON: decision, allowed, blocked, rule_codes, messages, suggested_fix and a summary the model can act on. It runs nothing.

import json
from langchain_vericto import VerictoSQLCheck

tool = VerictoSQLCheck(offline=True, dialect="postgres")
verdict = json.loads(tool.invoke({"query": "DELETE FROM users"}))
print(verdict["decision"], verdict["rule_codes"], verdict["suggested_fix"])
print(verdict["summary"])
BLOCKED ['VERICTO-001'] DELETE FROM users WHERE id = $1
Vericto blocked this query (VERICTO-001, severity critical). It was NOT executed. Suggested fix: DELETE FROM users WHERE id = $1 Rewrite the query following the suggested fix and try again.

Called with a model-generated ToolCall, it returns a ToolMessage whose artifact is the verdict as a dict:

# Usually generated by the model; built by hand here.
tool_call = {"args": {"query": "DROP TABLE users"}, "id": "1", "name": tool.name, "type": "tool_call"}
message = tool.invoke(tool_call)
print(message.artifact["decision"], message.artifact["rule_codes"])
BLOCKED ['VERICTO-010']

Guard a database: VerictoSQLDatabase

VerictoSQLDatabase is a SQLDatabase whose statements Vericto checks before they run, in the dialect of the SQLAlchemy engine. A blocked statement is not executed: run and run_no_throw return a message with the rule and the fix, so the model can correct its query. With on_block="raise" it raises vericto.VerictoBlocked.

from langchain_vericto import VerictoSQLDatabase

db = VerictoSQLDatabase.from_uri("sqlite:///shop.db", offline=True)
print(db.run("DELETE FROM orders"))
print(db.run("SELECT id, total FROM orders WHERE id = 1"))
Error: Vericto blocked this query (VERICTO-001, severity critical). It was NOT executed.
Suggested fix: DELETE FROM orders WHERE id = $1
Rewrite the query following the suggested fix and try again.
[(1, 9.5)]
import vericto

strict = VerictoSQLDatabase.from_uri("sqlite:///shop.db", offline=True, on_block="raise")
try:
    strict.run("DELETE FROM orders")
except vericto.VerictoBlocked as e:
    print("VerictoBlocked:", e)
VerictoBlocked: Query blocked by VERICTO-001 (severity critical). Suggested fix: DELETE FROM orders WHERE id = $1

Real output: langchain-vericto 0.1.0 from PyPI with CLI 2.4.0 in offline mode, on Python 3.13 and macOS on November 16, 2026. The SDK also logs every verdict that is not ALLOWED to stderr, for example vericto: statement BLOCKED rule=VERICTO-001 severity=critical event_id=-.

In an agent

LangChain's SQL toolkit on the guarded database, plus the check tool. This example needs a tool-calling model and its API key, so it was not run here; the other outputs on this page were.

# pip install -U "langchain[anthropic]"   (or the provider of your model)
from langchain.agents import create_agent
from langchain.chat_models import init_chat_model
from langchain_community.agent_toolkits import SQLDatabaseToolkit
from langchain_vericto import VerictoSQLCheck, VerictoSQLDatabase

db = VerictoSQLDatabase.from_uri("sqlite:///shop.db", offline=True)
model = init_chat_model("claude-sonnet-4-6")

toolkit = SQLDatabaseToolkit(db=db, llm=model)
tools = [*toolkit.get_tools(), VerictoSQLCheck.from_database(db)]
agent = create_agent(
    model=model,
    tools=tools,
    system_prompt="Check every query with vericto_sql_check before running it, and never run a blocked query.",
)
agent.invoke({"messages": [{"role": "user", "content": "Delete all orders."}]})

JavaScript: @vericto/sdk/langchain

For LangChain.js 1.x (@langchain/core and @langchain/classic >= 1 < 2) with a TypeORM DataSource. Node.js 18 or later.

npm install @vericto/sdk @langchain/classic @langchain/core typeorm
npm install better-sqlite3   # or your database's TypeORM driver: pg, mysql2, mssql, oracledb

# Offline mode: the Vericto CLI, 2.1.0 or later (2.4.0 is current)
npm install -D @vericto/vericto-cli          # or on PATH, or VERICTO_CLI=/path/to/vericto
export VERICTO_OFFLINE=1                     # or new Vericto({ offline: true }) in code

# Online mode: your workspace
export VERICTO_API_KEY=vtro_...              # scope proxy:evaluate
export VERICTO_DATABASE_ID=<database-id>

VerictoSqlDatabase extends LangChain's SqlDatabase: its DataSource checks every query, the agent's, the sample rows getTableInfo puts in the prompt and the SQL SqlDatabaseChain generates. A block goes back to the model as a message (onBlock: 'return', the default) or rejects with VerictoBlockedError (onBlock: 'raise').

import { DataSource } from 'typeorm';
import { VerictoSqlDatabase } from '@vericto/sdk/langchain';

const appDataSource = new DataSource({ type: 'better-sqlite3', database: 'shop.db' });
await appDataSource.initialize();

// Reads VERICTO_* from the environment; the dialect comes from the TypeORM type.
const db = await VerictoSqlDatabase.fromDataSourceParams({ appDataSource });
console.log(await db.run('DELETE FROM orders'));
Vericto blocked this SQL query; it was NOT executed.
Rule: VERICTO-001 (severity critical)
Suggested fix: DELETE FROM orders WHERE id = $1
Use the suggested fix, or rewrite the query so that it complies with the rule, and try again.

With createSqlAgent, VerictoSqlToolkit brings VerictoQuerySqlTool, which lets Vericto's errors through to your code instead of turning them into text for the model. VerictoCheckSqlTool only checks.

import { createSqlAgent } from '@langchain/classic/agents/toolkits/sql';
import { VerictoCheckSqlTool, VerictoSqlToolkit } from '@vericto/sdk/langchain';

// llm: your chat model (ChatOpenAI, ChatAnthropic...). The run below used a scripted
// model that answers in the ReAct format, so it made no model call.
const agent = createSqlAgent(llm, new VerictoSqlToolkit(db, llm));
const result = await agent.invoke({ input: 'Delete order 2' });
console.log(result.intermediateSteps[0]?.observation.split('\n')[0]); // what the model read
console.log(result.output);
console.log(await appDataSource.query('SELECT id FROM orders')); // the unchecked DELETE never ran

// A check-only tool: asks Vericto, runs nothing.
const check = new VerictoCheckSqlTool({ db });
console.log(await check.invoke('DROP TABLE orders'));
Vericto blocked this SQL query; it was NOT executed.
deleted order 2
[ { id: 1 } ]
Vericto blocked this SQL query.
Rule: VERICTO-010 (severity critical)
Suggested fix: Use a versioned migration tool (Flyway, Prisma Migrate, Alembic, Rails migrations)
Use the suggested fix, or rewrite the query so that it complies with the rule, and try again.

For another chain or your own code: guardDataSource wraps a DataSource so that query() goes through Vericto, and describeVerdict turns a verdict into the text the model reads.

import { Vericto } from '@vericto/sdk';
import { guardDataSource, describeVerdict } from '@vericto/sdk/langchain';

const vericto = new Vericto();
const guarded = guardDataSource(appDataSource, vericto, 'sqlite'); // query() is checked first
try {
  await guarded.query('DELETE FROM orders');
} catch (e) {
  console.log(e.constructor.name + ':', e.message);
}
console.log(describeVerdict(await vericto.check('DROP TABLE orders', 'sqlite')));
VerictoBlockedError: Query blocked by VERICTO-001 (severity critical). Suggested fix: DELETE FROM orders WHERE id = $1
Vericto blocked this SQL query.
Rule: VERICTO-010 (severity critical)
Suggested fix: Use a versioned migration tool (Flyway, Prisma Migrate, Alembic, Rails migrations)
Use the suggested fix, or rewrite the query so that it complies with the rule, and try again.

Real output: @vericto/sdk 0.6.0 from npm in offline mode (VERICTO_OFFLINE=1) with CLI 2.4.0, @langchain/classic 1.0.61, @langchain/core 1.4.1 and typeorm 1.1.3, on Node.js 25.8.0 and macOS on November 16, 2026. Online, the rules, severities and fixes are your workspace's.

To choose the mode in code instead of the environment, pass your own client:

// Offline: the local engine of the Vericto CLI.
import { Vericto } from '@vericto/sdk';

const db = await VerictoSqlDatabase.fromDataSourceParams({
  appDataSource,
  vericto: new Vericto({ offline: true }), // or VERICTO_OFFLINE=1
});

Fail closed

When Vericto cannot answer (the CLI is missing, the API does not respond, the key is wrong), the default mode is closed: in Python fail_mode="closed" raises vericto.VerictoUnavailable, in JavaScript it rejects with VerictoUnavailableError, and nothing runs. That error is never turned into a message for the model. In open mode the query runs unevaluated and the check tool answers UNEVALUATED with the reason. See Fail closed and retries.

Limits

  • Offline checks the 42 standard rules only: no custom rules or severity overrides, no masking, no agent allowlists, no business policies and no audit trail. All of that needs online mode.
  • The control point is your code. Only the SQL that goes through these objects is checked. Another connection to the same database does not go through Vericto; that is what the TCP proxy is for.
  • A verdict does not know your intent: it checks that a WHERE exists and is not always true, not which rows it touches.