Integrations
LangGraph Integration
AgentTrustNode for LangGraph state machine governance.
LangGraph Integration
Overview
The LangGraph adapter provides AgentTrustNode — a governance node you add to your LangGraph state graph. It validates agent output at a defined point in the graph execution.
Tier: Team+
Why It Matters
LangGraph agents need in-graph governance checkpoints, not just post-hoc validation. AgentTrustNode integrates natively with graph state and routing.
Prerequisites
pip install "agentrust-sdk[langgraph]"
# Team+ API key requiredStep-by-Step Guide
1. Import adapter
from agentrust_sdk.adapters.langgraph import AgentTrustNode2. Add node to graph
from langgraph.graph import StateGraph
governance = AgentTrustNode(agent_id="langgraph-agent")
graph = StateGraph(AgentState)
graph.add_node("agent", agent_node)
graph.add_node("governance", governance)
graph.add_edge("agent", "governance")
graph.add_conditional_edges("governance", route_on_decision)3. Route on decision
def route_on_decision(state):
if state.get("decision") == "block":
return "error_handler"
return "END"4. Handle blocked outputs
The node sets governance fields in graph state. Check decision outcome before continuing.
Examples
See examples/langgraph_agent.py for a complete runnable graph.
from agentrust_sdk.adapters.langgraph import AgentTrustNode
from agentrust_sdk import embed_gateway
embed_gateway()
governance_node = AgentTrustNode(agent_id="research-graph")Best Practices
- Place governance node after LLM/tool nodes, before output delivery
- Use conditional edges to route
blockandescalateoutcomes - Pass
parent_envelope_idfor multi-node agent chains (Enterprise) - Set meaningful
agent_idper graph deployment
Common Mistakes
- Using without Team API key (
TierGateError) - Placing governance node before agent produces output
- Using
auto_instrument()instead ofAgentTrustNodefor graph-level control
Troubleshooting
| Issue | Fix |
|---|---|
TierGateError | Upgrade to Team tier |
| Node not in graph path | Verify edges connect through governance node |
| State missing output | Ensure upstream node writes output to state |