Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(graph-view): handle missing __start__ node for langgraph>=0.4 (#7215)

Hassieb Pakzad2e94bc9e0977
diff --git a/web/src/features/trace-graph-view/components/TraceGraphView.tsx b/web/src/features/trace-graph-view/components/TraceGraphView.tsx
index 36ea286b31..8522d3712c 100644
--- a/web/src/features/trace-graph-view/components/TraceGraphView.tsx
+++ b/web/src/features/trace-graph-view/components/TraceGraphView.tsx
@@ -6,6 +6,7 @@ import {
type GraphCanvasData,
LANGGRAPH_END_NODE_NAME,
type AgentGraphDataResponse,
+ LANGGRAPH_START_NODE_NAME,
} from "../types";
type TraceGraphViewProps = {
@@ -69,7 +70,12 @@ function parseGraph(params: { agentGraphData: AgentGraphDataResponse[] }): {
const nodeToParentObservationMap = new Map<string, string>();
agentGraphData.forEach((o) => {
- const { node, step } = o;
+ const { node: rawNode, step } = o;
+
+ let node = rawNode;
+ try {
+ node = JSON.parse(rawNode);
+ } catch {}
stepToNodeMap.set(step, node);
@@ -84,6 +90,16 @@ function parseGraph(params: { agentGraphData: AgentGraphDataResponse[] }): {
LANGGRAPH_END_NODE_NAME,
o.parentObservationId,
);
+
+ // Also initialize the start node if it hasn't been seen yet
+ // Langgraph >= v4 is no longer adding a span for the start node
+ if (!nodeToParentObservationMap.has(LANGGRAPH_START_NODE_NAME)) {
+ stepToNodeMap.set(0, LANGGRAPH_START_NODE_NAME);
+ nodeToParentObservationMap.set(
+ LANGGRAPH_START_NODE_NAME,
+ o.parentObservationId,
+ );
+ }
}
// Only register id if it is top-most to allow navigation on node click in graph