langchainai-agentsmiddlewaresdk
LangChain agent middleware: verify tools before your chain executes
Wrap LangChain tool calls with Sanctum verifyAction() or protectAgent() — policies, human approval, and audit without rewriting your agent graph.
May 12, 20267 min read
LangChain agents chain tools, memory, and models. The dangerous step is always tool execution. Wrap calls with Sanctum — middleware style or protectAgent() from the agent adapter.
Two integration paths
- Per-tool wrapper — verify before each tool.invoke()
- protectAgent() — adapter hooks the agent loop automatically
Policies follow action names
Map LangChain tool names to Sanctum actions: send_email, run_sql, delete_file. Set verify on destructive ops, approve on reads.
More: all posts · runtime trust layer · open Sanctum Console
