Node-Level Observability for LangChain and LangGraph.
LangLens is a lightweight visual tracer and debugger designed specifically for LLM-powered applications. It captures detailed execution logs from your agents and chains, allowing you to inspect every LLM call, tool execution, and state transition with precision.
.langlens file.LangLens bridges the gap between your LLM execution and visual debugging:
graph TD
subgraph "Capture Phase"
A[LLM App] -- "1. LangChain Callbacks" --> B(LangLens Handler)
B -- "2. Stream Events" --> C[[.langlens file]]
end
subgraph "Visualization Phase"
C -- "3a. CLI Server" --> D[Web Browser]
C -- "3b. Custom Editor" --> E[VS Code IDE]
D --> F{Interactive UI}
E --> F
F -- "4. Inspect Nodes" --> G[Observability & Debugging]
end
LangLensCallbackHandler hooks into LangChain's event system to record starts, ends, and errors of every chain, tool, and LLM call..langlens file (JSONL format), providing a portable trace of the entire execution..langlens files, embedding the same Svelte UI directly into your workspace.Install LangLens via pip:
pip install langlens
Install the LangLens Viewer from the VS Code Marketplace.
Add the LangLensCallbackHandler to your LangChain or LangGraph execution config.
from langlens import LangLensCallbackHandler
from langchain_openai import ChatOpenAI
# Initialize the handler (creates a logs.langlens file)
handler = LangLensCallbackHandler(filename="logs.langlens")
# Attach it to your run
llm = ChatOpenAI()
config = {"callbacks": [handler]}
response = llm.invoke("How does a sunrise look from Mars?", config=config)
Run the following command to start a local server and open the viewer in your browser:
langlens visualize logs.langlens
Simply open any .langlens file. The LangLens Viewer will automatically render the interactive trace.
Build the Web UI: This bundles the Svelte app and copies assets to the Python and VS Code extension folders.
./build_ui.sh
Install Python Package (Editable mode):
pip install -e .
VS Code Extension:
vscode-extension folder in VS Code.pnpm install.F5 to start the Extension Development Host.To build distribution packages manually:
./scripts/package.sh
This project is licensed under the MIT License.