Documentation Index
Fetch the complete documentation index at: https://docs.langsight.dev/llms.txt
Use this file to discover all available pages before exploring further.
What You Get
LangSight provides comprehensive observability and runtime safety for LangGraph agents with zero configuration required. Every node execution, LLM call, tool invocation, and conditional edge traversal is captured automatically.Graph Topology
Visualize the entire StateGraph structure — nodes, edges, conditional branches — as an interactive DAG in the dashboard
Loop Detection
Catch infinite loops before they burn through your budget — configurable node iteration limits with automatic termination
Budget Enforcement
Per-session cost caps enforced at runtime — stop execution when cumulative cost exceeds your limit
Zero-Config Setup
auto_patch() installs monkey-patches on langgraph.pregel.Pregel.{stream,astream,invoke,ainvoke} and StateGraph.compile(). Your existing code runs unchanged — no callback wiring required.What Gets Captured
Every graph execution produces detailed traces with 12 critical data points:| Data Point | Source | Description |
|---|---|---|
| Node name | metadata["langgraph_node"] | The node that executed (e.g., "planner", "generate") |
| Node inputs | on_chain_start | The state dict passed to the node |
| Node outputs | on_chain_end | The state dict returned by the node |
| LLM messages | on_chat_model_start | Full prompt + chat history sent to the model |
| Model ID | kwargs["model"] | Model name (e.g., "gpt-4", "claude-sonnet-4-6") |
| Input tokens | usage_metadata["input_tokens"] | Prompt tokens consumed |
| Output tokens | usage_metadata["output_tokens"] | Completion tokens generated |
| Thinking tokens | Derived (see below) | Extended thinking tokens (for models with CoT) |
| Latency | Wall-clock measurement | Per-node and per-LLM-call latency in milliseconds |
| Cost | Pricing table lookup | USD cost computed from token counts + model pricing |
| Graph topology | StateGraph.compile() | Full graph structure: nodes, edges, conditional branches |
| Parent-child relationships | run_id tracking | Which node spawned which tool call or sub-agent |
| Conditional edges | Builder metadata | Branches taken during execution (e.g., continue vs. end) |
Graph Topology Capture
When you callStateGraph.compile(), LangSight patches the compile step to extract and stash the graph structure:
invoke() or ainvoke() call and rendered as an interactive graph in the dashboard.
How It Works
auto_patch()wrapsStateGraph.compile()- When you call
compiled_graph = graph.compile(), the wrapper:- Calls the original
compile() - Extracts
nodes,edges,branches, andentry_pointfrom the builder - Stashes the topology as
_langsight_topologyon the compiled graph object
- Calls the original
- On the first
ainvoke()call, the patched method reads_langsight_topologyand emits a topology span - The dashboard receives the topology and renders it in the Topology tab
Topology capture is idempotent — calling
compile() multiple times on the same graph does not create duplicate topology spans.Node Deduplication
LangGraph’sainvoke() internally calls astream(), which fires on_chain_start twice for the same node: once for the outer invoke and once for the inner stream iteration. Without deduplication, this produces duplicate node spans in the trace.
LangSight uses _active_lg_nodes to track which nodes are currently executing:
on_chain_end fires, the node is removed from _active_lg_nodes so subsequent invocations of the same node are treated as separate executions.
Loop Detection
LangSight enforces a node iteration limit to catch infinite loops before they consume your entire budget. This is separate from the tool-call loop detection in Prevention Config.How It Works
Every time a node executes, LangSight increments a counter for that node name:GraphLoopDetectedError is raised and the session is tagged loop_detected in the dashboard.
Configuration
Set the limit per session viaLangSightClient:
Catching the Exception
Budget Enforcement
LangSight tracks cumulative LLM cost across all nodes in a session and enforces a hard budget limit at runtime.How It Works
-
Cost accumulation: Every time
on_llm_endfires, LangSight computes the cost from token counts and adds it to the session’s running total: -
Flag-based termination: LangSight does not raise immediately in
on_llm_endbecause that would interrupt the current node mid-execution. Instead, it sets a flag and raises on the nexton_chain_start:
Configuration
Set a per-session budget viaLangSightClient:
Catching the Exception
Pricing Table
LangSight uses a built-in pricing table for major models (Claude, GPT-4, Gemini). For custom or fine-tuned models, provide your own pricing:Thinking Tokens
For models that support extended thinking (e.g., Claude Sonnet with chain-of-thought, GPT-o1 reasoning mode), LangSight captures thinking tokens separately from input/output tokens.How It Works
LangChain’susage_metadata includes three token counts:
total_tokens > input_tokens + output_tokens, the difference is attributed to thinking.
Pricing
Thinking tokens are priced separately. For Claude Sonnet 4.6:- Input: $3.00 / 1M tokens
- Output: $15.00 / 1M tokens
- Thinking (extended): $3.00 / 1M tokens (same as input)
Dashboard Views
Session Summary
The Sessions page shows all graph executions in a project:| Column | Description |
|---|---|
| Session ID | Unique identifier for the graph invocation |
| Agent Name | Top-level graph name (auto-detected from StateGraph) |
| Status | success, error, loop_detected, budget_exceeded |
| Duration | Wall-clock time from ainvoke() start to finish |
| Cost | Cumulative LLM cost across all nodes |
| Nodes Executed | Count of unique nodes executed |
| Health Tags | loop_detected, budget_exceeded, stale, etc. |
Topology Tab
Click a session to open the detail view. The Topology tab shows:- Interactive DAG: Nodes rendered as boxes, edges as arrows, conditional branches highlighted
- Execution path: Nodes that executed are highlighted in green; unexecuted nodes are grey
- Hover tooltips: Node name, input/output summary, latency, cost
- Zoom and pan: Navigate large graphs with 100+ nodes
Trace Tab
The Trace tab shows a parent-child tree of all spans:- Node/tool/LLM name
- Latency in milliseconds
- Cost in USD
- Status (
success,error,timeout) - Input/output payloads (expandable)
Comparison with LangSmith
LangSight and LangSmith both provide observability for LangGraph, but LangSight adds runtime safety features that LangSmith does not.| Feature | LangSmith | LangSight |
|---|---|---|
| Capture node inputs/outputs | ✅ | ✅ |
| LLM token tracking | ✅ | ✅ |
| Parent-child span hierarchy | ✅ | ✅ |
| Cost calculation | ✅ | ✅ |
| Graph topology visualization | ❌ | ✅ |
| Loop detection + termination | ❌ | ✅ |
| Runtime budget enforcement | ❌ | ✅ |
| Thinking token capture | Partial | ✅ |
| Zero-config instrumentation | ❌ (requires callback wiring) | ✅ (one-line auto_patch()) |
| Per-project MCP server catalog | ❌ | ✅ |
| Health checks for MCP servers | ❌ | ✅ |
Troubleshooting
Graph is not instrumented
Symptom: No spans appear in the dashboard after running your graph. Solutions:-
Ensure
auto_patch()is called before importinglanggraph: -
Check that
LANGSIGHT_URL,LANGSIGHT_API_KEY, andLANGSIGHT_PROJECT_IDare set. -
Verify the LangSight backend is reachable:
Loop detection fires too early
Symptom:GraphLoopDetectedError is raised for graphs that intentionally iterate multiple times.
Solutions:
-
Increase the node iteration limit:
-
Disable loop detection if your graph has unbounded iteration:
Budget enforcement triggers after limit is exceeded
Symptom: The session continues past the budget limit before terminating. Explanation: Budget enforcement is flag-based — LangSight checks the budget after each LLM call completes, but only raises on the nexton_chain_start. This means the node that triggered the budget violation always completes before the session is terminated.
Solution: Set your budget limit slightly lower than your hard cap to account for the final node’s cost:
Thinking tokens are not captured
Symptom:thinking_tokens is null in the dashboard even though the model supports extended thinking.
Cause: LangChain’s usage_metadata does not include total_tokens for some providers.
Solution: Verify that your LangChain integration populates total_tokens in usage_metadata. If not, file an issue with LangChain or use LangSight’s direct SDK integration instead:
Topology does not appear in dashboard
Symptom: The Topology tab shows “No topology data available” even though the graph executed successfully. Cause:StateGraph.compile() was called before auto_patch().
Solution: Move auto_patch() to the top of your script, before any StateGraph imports or instantiations.
Using langchain_mcp_adapters with auto_patch()
Symptom:TypeError: _patched_call_tool() got an unexpected keyword argument 'progress_callback' when calling MCP tools.
Cause: Fixed in v0.14.16. Earlier versions of LangSight’s MCP autopatch did not forward unknown keyword arguments (such as progress_callback used by langchain_mcp_adapters) to the original call_tool method.
Fix: Upgrade to v0.14.16 or later:
auto_patch() now passes all kwargs through transparently, making it fully compatible with langchain_mcp_adapters and any other library that extends the MCP call_tool signature.
Related
- LangChain Integration — LangSight’s unified callback for LangChain and LangGraph
- Prevention Config (Guards) — Dashboard-configured loop detection, budget controls, and circuit breakers
- Session Health — Full health tag reference including
loop_detectedandbudget_exceeded - Costs & Model Pricing — How LangSight computes session costs and thinking token pricing