Framework integration

LangGraph

Secure LangGraph tool calls before graph compilation while preserving graph state and runtime behavior.

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

tools = [customer_read, customer_delete]
middleware = security.langgraph(
    agent_id="support-agent",
    tools=tools,
    permissions={
        "customer.read": "ALLOW",
        "customer.delete": "DENY",
    },
)
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

Middleware must be present before the graph is compiled. Do not retain an unwrapped tool path for sensitive operations.