NeMo Relay LangGraph Integration

View as Markdown

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 add "nemo-relay[langgraph]"

Installing the langgraph extra also installs the LangChain integration dependencies.

Usage Example

1from typing_extensions import TypedDict
2
3import nemo_relay
4from langgraph.graph import END, START, StateGraph
5from nemo_relay.integrations.langgraph import NemoRelayCallbackHandler
6
7class State(TypedDict):
8 value: int
9
10def increment(state: State) -> State:
11 return {"value": state["value"] + 1}
12
13builder = StateGraph(State)
14builder.add_node("increment", increment)
15builder.add_edge(START, "increment")
16builder.add_edge("increment", END)
17
18graph = builder.compile()
19
20with nemo_relay.scope.scope("langgraph-request", nemo_relay.ScopeType.Agent):
21 result = graph.invoke(
22 {"value": 1},
23 config={"callbacks": [NemoRelayCallbackHandler()]},
24 )
25
26print(result)

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:

1from langchain.agents import create_agent
2from langchain_core.runnables import RunnableConfig
3from nemo_relay.integrations.langgraph import NemoRelayMiddleware
4
5agent = create_agent(
6 model="nvidia:nvidia/nemotron-3-nano-30b-a3b",
7 tools=[],
8 middleware=[NemoRelayMiddleware()],
9)
10
11def agent_node(state: dict, config: RunnableConfig) -> dict:
12 return agent.invoke({"messages": state["messages"]}, config=config)

Install the NVIDIA LangChain provider if you want to run the nested agent example as written:

$uv add "nemo-relay[langgraph,langchain-nvidia]"

Observability

Refer to Observability for details on exporting NeMo Relay observability data to third-party systems.