Working with LangGraph

Automatically instrument LangChain chains and agents with LangDB—gain live traces, cost analytics, and latency insights through init().

LangDB provides seamless tracing and observability for LangChain-based applications.

Installation

Install the LangDB client with LangChain support:

Quick Start

Export Environment Variables

Initialize LangDB

Import and run the initialize before configuring your LangChain/LangGraph:

Define your Agent

Once LangDB is initialized, all calls to llm, intermediate steps, tool executions, and nested chains are automatically traced and linked under a single session.

Complete LangGraph Agent Example

Here is a full LangGraph example based on ReAct Agent which uses LangDB Tracing.

Example code

Check out the full sample on GitHub: https://github.com/langdb/langdb-samples/tree/main/examples/langchain/langgraph-tracingarrow-up-right

Setup Environment

Install the libraries using pip

Export Environment Variables

main.py

Running your Agent

Navigate to the parent directory of your agent project and use one of the following commands:

Output

Traces on LangDB

When you run queries against your agent, LangDB automatically captures detailed traces of all agent interactions:

Next Steps: Advanced LangGraph Integration

This guide covered the basics of integrating LangDB with LangGraph using a ReAcT agent example. For more complex scenarios and advanced use cases, check out our comprehensive resources in Guides Section.

Last updated

Was this helpful?