Impraint
Integrations

LangGraph

Node-level tracking for LangGraph agents.

ImpraintGuardLangGraphCallbackHandler extends the LangChain handler and adds graph awareness: each LangGraph node is recorded as its own graph_node step. LLM and tool calls inside nodes are tracked exactly as they are with LangChain.

Install

pip install "impraint-guard[langgraph,gemini]"

This needs langgraph 0.4.5 or newer and langchain-core 1.6.0 or newer.

Usage

import os
from impraint_guard import Guard
from impraint_guard.integrations.langgraph import ImpraintGuardLangGraphCallbackHandler

guard = Guard(api_key=os.environ["IMPRAINT_API_KEY"], agent_id="orchestrator")
handler = ImpraintGuardLangGraphCallbackHandler(guard)

graph = build_your_state_graph().compile()

@guard.track
def run(question: str):
    return graph.invoke(
        {"question": question},
        config={"callbacks": [handler]},
    )

Streaming works too: use graph.stream with the same config.

Same rules as LangChain

Pass the handler through config={"callbacks": [...]} at invoke or stream time, and call the graph from inside a @guard.track function.

Multi-agent graphs

If one graph hands work to a second agent with its own Guard, call that agent's tracked function from inside the first one. Guard links the traces automatically. See Cross-agent escalation.

Prompt checks

Like the LangChain handler, this handler checks the text going into the model and reports what it finds by default (on_input="report"). Pass on_input="block" or on_input="off" when you create it to change that. See Content safety for what is checked and what each mode does.

On this page