Framework integration

LangChain

Use AgentSecurity middleware with LangChain create_agent so tool authorization happens immediately before supported local execution.

Install

pip install 'agent-security[langgraph]'

Define local tools

Keep each business capability as a named local tool. Stable tool names become policy actions, with underscores normalized to dots where supported.

Secure the agent

from langchain.agents import create_agent

tools = [customer_read, email_send]
middleware = security.langgraph(
    agent_id="support-agent",
    name="Support Agent",
    tools=tools,
    permissions={
        "customer.read": "ALLOW",
        "email.send": "REQUIRE_APPROVAL",
    },
)
agent = create_agent(model=model, tools=tools, middleware=[middleware])

Runtime behavior

  • Agent and tool metadata sync at construction/startup.
  • Newly discovered tools receive default-DENY.
  • A denied or approval-required tool implementation does not execute.
  • Transport exhaustion fails closed.

Limits

Install middleware when the agent is created. Attaching it after construction is not a verified security boundary.