LangGraph instrumentation
parlotize() for LangGraph / LangChain agents.
parlot-instrumentation-langgraph registers a global LangChain callback handler via
LangChain’s register_configure_hook so every invoke / ainvoke / astream emits
Parlot Conversation Contract spans plus OpenTelemetry generative AI (GenAI) operational spans.
Quick start
from parlot.instrumentation.langgraph import parlotize, close_session
parlotize("support-bot", version="0.1.0")
graph.invoke(
{"messages": [("user", "Hello")]},
config={"configurable": {"thread_id": "demo-1"}},
)
close_session("demo-1") # optional; also flushed on process exitEnvironment: PARLOT_ENDPOINT, PARLOT_API_KEY — see Environment Variables.
parlotize() options: Interactive API Reference
(LangGraph-only kwargs include channel and modality; see also close_session).
For standalone (non-LiveKit) sessions, set channel= (e.g. "webchat") and optionally
modality= so ingest treats the session as text:
parlotize("support-bot", version="0.1.0", channel="webchat", modality="text")Generative AI content capture is shared across adapters — see
Concepts → Generative AI content capture.
Override for the process with parlotize(capture_genai_content=False).
See examples/langgraph/minimal-agent.
Span vocabulary
| Layer | Spans |
|---|---|
| Contract | parlot.session, parlot.turn, parlot.session.close |
| GenAI (OpenTelemetry semantic conventions v1.41) | invoke_agent, invoke_workflow, chat / chat {model}, execute_tool {name} |
Session key is LangGraph thread_id. session.modality is set when you pass modality=,
or when channel is a messaging channel (webchat, sms, whatsapp) or voice.
Otherwise modality stays unset. If thread_id is omitted, Parlot creates one automatically
(anon-…) for the process lifetime.
LiveKit + LangGraph
When a LiveKit voice agent uses livekit.plugins.langchain.LLMAdapter, call both:
from parlot.instrumentation.livekit import parlotize as parlotize_livekit
from parlot.instrumentation.langgraph import parlotize as parlotize_langgraph
parlotize_livekit("voice-bot", version="0.1.0")
parlotize_langgraph("voice-bot") # adopts LiveKit TracerProvider when already set- LiveKit owns
parlot.session/parlot.turn(voice). - LangGraph emits nested GenAI ops (
chat,execute_tool,invoke_workflow) under the active OpenTelemetry context (LiveKit’s remappedchatspan). - Contract spans stay on the LiveKit session (no duplicates).
