Durable LangGraph Agents on Temporal with Langfuse Tracing by Mohsin SheikhaniDurable LangGraph Agents on Temporal with Langfuse Tracing by Mohsin Sheikhani

Durable LangGraph Agents on Temporal with Langfuse Tracing

Portfolio project
Mohsin Sheikhani
If the process running a LangGraph agent dies halfway, what brings it back? This project answers that at the smallest scale: a two-node LLM graph run on Temporal and traced end to end in Langfuse.

How it works

Each LangGraph node runs as a Temporal activity, so its result is saved in the workflow's event history. A worker that crashes and restarts skips the nodes that already finished and resumes at the one that didn't
Timeouts and retry policies are set per node, so a cheap step and an expensive model call don't share one budget
Model calls go through LiteLLM, so switching provider is a config change. LiteLLM's own retries are off, so every retry shows up in Temporal and Langfuse instead of being hidden in the client
A status query reports which node the run is on, without adding anything to the event history

The tracing problem

A Langfuse callback assumes one process and one run. Temporal splits the work across a client and workers, and replays workflow code after a crash, so a normal setup gives broken traces and duplicate spans. I passed the trace context through Temporal headers and used Temporal's replay-safe tracer provider, so each run lands as one clean trace. Filtering out status-poll spans cut the trace from 28 spans to 10.

Stack

Python, LangGraph, Temporal, LiteLLM, OpenTelemetry, Langfuse

0 likes · 0 views · Dec 1, 2026

Runs a LangGraph graph on Temporal so a crashed worker resumes at the failed node, with replay-safe tracing into Langfuse as one clean trace.

Tags