Flow 09 / 14PackagesLangChain / LangGraph11 tests
LangChain — veilgate-langchain
A LangChain Runnable that redacts PII and secrets from chat messages on the way in and re-hydrates the model response on the way out.
peer · @langchain/core v0.3+
veilgate-langchain wraps any invokable model in a RunnableLambda that
redacts chat messages before the call and re-hydrates the reply after. 11 tests.
terminal
npm install veilgate-langchainPeer dependency: @langchain/core (v0.3+).
withRedaction(model, options?)
chain.ts
import { withRedaction } from "veilgate-langchain";
import { PRESETS } from "veilgate-policy";
const safe = withRedaction(model, { policy: PRESETS["soc2-secrets"] });
await safe.invoke([
{ role: "system", content: "You are helpful." },
{ role: "user", content: "My name is Alice Johnson." },
]);
// the model receives redacted messages; the response is re-hydratedBecause it returns a Runnable, it composes into any LangChain or LangGraph chain in place of
the raw model.
Lower-level helpers
helpers.ts
import { redactMessages, rehydrateMessage } from "veilgate-langchain";
const { messages, vault, blocked } = await redactMessages(original, { policy });
// ... call the model with `messages` ...
const restored = rehydrateMessage(responseMessage, vault);Exports
| Export | Purpose |
|---|---|
withRedaction |
Wrap an invokable model in a redaction RunnableLambda |
redactMessages |
Redact an array of chat messages |
rehydrateMessage |
Re-hydrate a single response message against a vault |
RedactionBlockedError |
Thrown when a message produces a BLOCK decision |
Note
withRedaction is fail-closed: a BLOCK decision throws RedactionBlockedError rather than
invoking the model.