Skip to main content
Attesta integrates with LangChain and LangGraph at two levels:
  1. Tool wrapping — replace every tool’s func/coroutine with a gated version that evaluates risk before execution.
  2. Graph node — insert a gate node into a LangGraph StateGraph that filters tool calls between the agent and tool-execution nodes.

Installation


Tool Wrapping (Python)

AttestaToolWrapper wraps a list of LangChain tools so that every invocation passes through Attesta approval. The original tool objects are mutated in-place (their func and coroutine attributes are replaced).

API

Methods:

Full Example

Behavior on Denial

When a tool call is denied, the wrapper returns a string message instead of raising an exception. This allows the LLM agent to understand the denial and suggest alternatives:
Both sync (func) and async (coroutine) paths are wrapped. If your tool has a coroutine attribute, the async path is also gated. The wrapper auto-detects whether it is running inside an existing event loop (e.g., Jupyter or LangServe) and handles both cases.

Tool Wrapping (TypeScript)

The TypeScript SDK provides gatedTool which wraps a LangChain tool’s invoke method using a Proxy.

API

Full Example


LangGraph Node (Python)

attesta_node() returns an async function suitable for use as a LangGraph node. Insert it between the agent node and the tool-execution node so that only approved tool calls are forwarded.

API

Returns an async node function with signature async (state: dict) -> dict. The function:
  1. Reads tool_calls from the last message in state["messages"]
  2. Evaluates each tool call through attesta.evaluate()
  3. Replaces tool_calls on the message with only the approved subset
  4. Returns the modified state

Full Example

Denied tool calls are silently removed from the message’s tool_calls list. The agent will see fewer tool calls than it requested. This is intentional — it prevents the agent from retrying denied actions in the same turn. If you want the agent to receive explicit denial messages, use AttestaToolWrapper instead.

LangGraph Node (TypeScript)

The TypeScript SDK provides createGateNode for LangGraph.
The gate node adds _attesta metadata to the state on approval, or throws AttestaDenied on denial.

Risk Overrides

Force specific risk levels for sensitive tools using risk_overrides:
This bypasses the risk scorer’s heuristic for named tools while keeping all other pipeline stages (challenge, verification, audit) intact.

OpenAI Agents SDK

Approval handler and tool guardrails

MCP Integration

Gate any MCP server with zero code changes