Blog

Runtime authorization

langchainai-agentsmiddlewaresdk

LangChain Agent Middleware: Verify Tools Before Execution

Wrap LangChain tool calls with 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

  1. Per-tool wrapper — verify before each tool.invoke()
  2. 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.

Documentation · MCP gate · Action approval

Guides: agentic AI risk · MCP security · runtime authorization · HITL approvals · coding agents · get startedMore: all posts · AI trust layer · open Sanctum Console

Give every agent action a trust boundary.

Start with Connect Agent, keep the SDK path for deeper fleets, and prove exactly what was approved, blocked, or contained.