NeMo Relay LangGraph Integration
Use the nemo_relay.integrations.langgraph package to add NeMo Relay
observability to LangGraph workflows through public LangGraph APIs.
Setup
Install the LangGraph integration extra in your application environment.
uv
pip
Installing the langgraph extra also installs the LangChain integration
dependencies.
Usage Example
Managed ToolNode Calls
For a standalone LangGraph ToolNode, construct the node with
create_tool_node. It routes each model-requested tool call through Relay’s
managed execution pipeline while preserving LangGraph state, store, and runtime
argument injection.
NemoRelayCallbackHandler records the graph lifecycle and provides its scopes.
create_tool_node provides managed tool execution. Use both for complete
standalone LangGraph instrumentation. For custom ToolNode wrapper composition,
construct ToolNode directly and pass wrap_tool_call and awrap_tool_call
from this integration.
Served LangChain Agents
When you export a LangChain agent for langgraph dev or langgraph up, add
the Relay callback handler to the compiled graph before exporting it. Request
callbacks are not part of the serialized LangGraph API request.
configure_graph stores a NemoRelayCallbackHandler in the graph’s base
configuration and returns the same compiled graph, so the LangGraph server can
load it. The callback handler creates the graph and node scopes. The middleware
routes model and tool calls through Relay under those scopes.
The handler closes each graph scope on the stack where it started. This works
even when the server runs the completion callback in a different context.
Successful runs emit an end event with status OK. Failed runs emit an end
event with status ERROR.
For tracked runs, Graph Interrupt and Graph Resume marks belong to the graph
scope identified by their run ID, including when the server delivers them in a
different context. When the run ID is absent or untracked, the marks use the
current scope.
For LangChain agents inside a LangGraph workflow, use NemoRelayMiddleware from
this package the same way as the LangChain integration and pass the LangGraph
config into the nested agent call:
Install the NVIDIA LangChain provider if you want to run the nested agent example as written:
uv
pip
Verify the Integration
The integration works correctly when:
graph.invoke(...)returns the incremented state from the example.- The
langgraph-requestscope contains the LangGraph run. - Nested LangChain agents inherit the same callback config when you pass the LangGraph
configthrough.
Observability
Refer to Observability for details on exporting NeMo Relay observability data to third-party systems.