Skip to main content
LangGraph is a library for building stateful, multi-actor applications with LLMs. Braintrust traces LangGraph applications through the LangChain callback system, capturing graph execution, node transitions, and model calls.

Setup

Install LangGraph alongside Braintrust and the LangChain packages you use:

Trace with LangGraph

Braintrust traces LangGraph through the LangChain callback system. Enable it without code changes through auto-instrumentation, or configure the callback handler manually. See Trace LLM calls for more about auto-instrumentation.

TypeScript auto-instrumentation

To trace LangGraph graphs without modifying your application code, initialize Braintrust normally, then run your app with Braintrust’s import hook to patch @langchain/core at runtime. Requires @langchain/langgraph v1 or later.
trace-langgraph-auto.js
Run it with the import hook:
The auto-instrumentation example uses plain JavaScript so node --import can run the file directly. The Braintrust APIs work the same in TypeScript projects — compile your TypeScript to JavaScript, then run the compiled file with the import hook.
If you’re using a bundler, see Trace LLM calls for plugin and loader setup.

Python auto-instrumentation

trace-langgraph-auto.py

Manual callback setup

If you want explicit control over the LangChain handler, configure it directly:
trace-langgraph.ts
LangGraph trace visualization in Braintrust showing the execution flow of nodes and their relationships

Resources