Back to Blog
Integrations

LangGraph + AgentTrust OS

Production governance for LangGraph agents — no graph restructuring required

Add policy enforcement, confidence scoring, and compliance audit trails to an existing LangGraph agent in under 30 minutes — without modifying your graph definition.

July 1, 202612 min read
LangGraphRuntime GovernanceTool Access ControlTrust RuntimePython
AgentTrust OS

LangGraph + AgentTrust OS

Adding production governance to LangGraph agents without changing your graph structure

TL;DR
  • LangGraph provides excellent state-machine orchestration for complex agent graphs. It does not provide tool-level access control, confidence scoring, or compliance audit trails.
  • AgentTrust OS wraps LangGraph node execution with runtime governance — adding policy enforcement and observability without modifying your graph definition.
  • The integration point is the tool call layer: wrap each ToolNode or custom tool with the AgentTrust runtime evaluator.
  • Every tool invocation gets a governance record: score, route decision, policy reference, and full parameter trace.
  • Setup takes under 30 minutes for an existing LangGraph agent.
Read the full integration guide →

LangGraph is one of the most capable frameworks available for building stateful, multi-step AI agents. Its graph-based architecture handles complex reasoning cycles, parallel execution branches, and state checkpointing in ways that simpler sequential frameworks can't match.

What LangGraph does not provide — by design — is governance infrastructure: access control for which nodes can invoke which tools, confidence scoring before irreversible actions, policy enforcement at the tool call level, or structured audit trails for compliance review. These are intentionally out of scope for an orchestration framework.

This tutorial shows exactly where and how to add AgentTrust OS governance to an existing LangGraph agent — without restructuring your graph, without changing your node logic, and without modifying the state model you've already built.

INTEGRATION ARCHITECTURE

Where governance wraps the graph

AgentTrust OS integrates at the tool execution layer — the boundary between your graph nodes and the external systems they call. This is the right place to enforce governance because it is the point of maximum leverage: all tool calls pass through it regardless of which node initiates them, and it is where irreversible actions happen.

Integration Point

You do not need to modify your LangGraph graph definition, StateGraph, or node functions. Governance wraps the tool execution environment that the graph calls into — keeping your graph logic clean and your governance logic separate.

STEP-BY-STEP SETUP

Adding AgentTrust OS to a LangGraph agent

01
Install the SDK
Shell
npm install @agenttrust/sdk
# or
pip install agenttrust-sdk
02
Define a policy for your graph

A policy file declares which tools are permitted, their trust level, and the confidence threshold required for autonomous execution.

TypeScript — policy definition
import { definePolicy } from "@agenttrust/sdk";

export const researchAgentPolicy = definePolicy({
  name: "research-agent-v1",
  tools: {
    web_search:      { trustLevel: "standard", threshold: 0.75 },
    read_file:       { trustLevel: "standard", threshold: 0.75 },
    write_file:      { trustLevel: "sensitive", threshold: 0.90 },
    send_email:      { trustLevel: "high-risk", threshold: 0.95,
                       requireApproval: true },
    delete_resource: { trustLevel: "critical", blocked: true },
  },
  defaults: { threshold: 0.80, trustLevel: "standard" },
});
03
Wrap your LangGraph ToolNode with the runtime evaluator
TypeScript — LangGraph integration
import { StateGraph, ToolNode } from "@langchain/langgraph";
import { AgentTrustRuntime } from "@agenttrust/sdk";
import { researchAgentPolicy } from "./policy";
import { tools } from "./tools"; // your existing tools

// Wrap the runtime around your tools — graph structure unchanged
const runtime = new AgentTrustRuntime({ policy: researchAgentPolicy });
const governedTools = runtime.wrapTools(tools);

// Use governed tools in your ToolNode — same API as before
const toolNode = new ToolNode(governedTools);

// Your graph definition is unchanged
const graph = new StateGraph(AgentState)
  .addNode("agent", callModel)
  .addNode("tools", toolNode)   // ← governed automatically
  .addEdge("tools", "agent")
  .addConditionalEdges("agent", routeToTools);

export const app = graph.compile();
04
Configure escalation handling

When an action scores below the autonomous threshold, Trust Runtime surfaces it to your escalation handler instead of executing.

TypeScript — escalation handler
const runtime = new AgentTrustRuntime({
  policy: researchAgentPolicy,
  onEscalate: async ({ action, score, signals }) => {
    // Route to your review queue, Slack, PagerDuty, etc.
    await reviewQueue.add({
      action,
      score,
      signals,
      agentId: "research-agent",
      timestamp: new Date().toISOString(),
    });
    // Return "pause" to halt workflow pending review
    // Return "reject" to block and continue with error
    return "pause";
  },
});
05
Access audit trails in Trust Audit

Every governed tool call generates a structured record in Trust Audit — no additional instrumentation required. Records include the full decision trace: composite score, each signal value, the routing decision, policy reference, and all action parameters.

TypeScript — querying audit records
import { TrustAudit } from "@agenttrust/sdk";

const audit = new TrustAudit();

// Get all tool calls for a workflow run
const records = await audit.query({
  agentId: "research-agent",
  runId:   workflowRunId,
  from:    "2026-07-01",
});

// Each record: { tool, score, signals, route, params, timestamp }
// Export as structured JSON for compliance review
FREQUENTLY ASKED QUESTIONS

Your questions, answered directly

Yes — AgentTrust OS governance operates at the tool execution layer, below the graph's checkpointing mechanism. LangGraph's state persistence works exactly as designed; the governance layer adds records to Trust Audit without affecting the graph's own state model.
Yes. Policies are attached per-tool, not per-graph. If you have nodes with different tool access requirements, define separate policies per tool set and use `runtime.wrapTools(tools, policy)` with the appropriate policy for each tool group. The graph structure is unchanged.
Trust Runtime raises a `GovernanceBlockedError` at the tool call site. LangGraph surfaces this as a tool invocation error, which your graph's error-handling logic can catch and route to a fallback node, escalation branch, or workflow termination — whatever your graph's error handling already does.
Schema conformance and policy alignment checks add under 20ms per tool call. Output consistency re-sampling (for high-risk tools) adds 100–300ms. For latency-sensitive graphs, configure re-sampling only for the tool trust levels that warrant it — typically `sensitive` and `high-risk` only.
GOVERN YOUR LANGGRAPH AGENTS

Production governance, 30-minute integration

Add Trust Runtime to your existing LangGraph agents. No graph restructuring required.

View LangGraph Integration →

More from the blog

AI ComplianceJuly 22, 2026AI ComplianceJuly 22, 2026AI GovernanceJuly 22, 2026AI GovernanceJuly 22, 2026AI ArchitectureJuly 22, 2026AI SecurityJuly 16, 2026MLOpsJuly 10, 2026AI ImplementationJuly 8, 2026AI Agent ArchitectureJuly 5, 2026AI Agent ArchitectureJune 30, 2026EngineeringJune 23, 2026AI Agent ArchitectureJuly 2, 2026AI Agent ArchitectureJuly 1, 2026IntegrationsJuly 1, 2026IntegrationsJuly 2, 2026AI SecurityJuly 3, 2026AI SecurityJuly 1, 2026AI ComplianceJuly 2, 2026AI ComplianceJuly 3, 2026AI StrategyJuly 2, 2026AI StrategyJuly 3, 2026AI StrategyJuly 3, 2026AI StrategyJuly 3, 2026AI GovernanceJuly 28, 2026Healthcare AIJuly 28, 2026ArchitectureJuly 29, 2026ArchitectureJuly 29, 2026AI StrategyJuly 29, 2026AI StrategyJuly 30, 2026AI SecurityJuly 30, 2026AI ComplianceJuly 30, 2026EngineeringJuly 30, 2026AI GovernanceAugust 4, 2026EngineeringAugust 4, 2026EngineeringAugust 4, 2026