Skip to main content
A LangGraph node calls ordinary LangChain models, so the LangChain options carry over. Two of them work inside a graph today; both were checked against langgraph 1.2 and langchain-core 1.6 in Python.

Auto-instrumentation

Call init() before the graph is built. Every model call made through a patched SDK is scanned, in whichever node it happens, sync or async. A block raises PromptGuardBlockedError out of graph.invoke().
This scans what reaches the model. Tool calls and tool results are scanned only as part of the next model call’s messages, not when the tool runs.

Guarding a node’s input

To scan, and redact, a value before a node uses it, invoke the inline guard inside the node. On a redact decision it returns the redacted value; on a block it raises.

Callback handler

Passing PromptGuardCallbackHandler in config={"callbacks": [...]} does not work in promptguard-sdk 2.3.0 and earlier: the handler fails under LangChain’s callback manager (see LangChain), and LangGraph additionally calls on_chain_start with no serialized definition, which the handler does not accept. Use one of the two options above.

Proxy

A ChatOpenAI pointed at the proxy works in a graph like anywhere else, in Python or LangGraph.js.