These samples demonstrate the Temporal LangGraph plugin, which runs LangGraph workflows as durable Temporal workflows. Each LangGraph graph node (Graph API) or @task (Functional API) executes directly inside a workflow or as a Temporal activity with automatic retries, timeouts, and crash recovery.
Samples are organized by API style:
- Graph API (
graph_api/) -- Define workflows asStateGraphwith nodes and edges. - Functional API (
functional_api/) -- Define workflows with@taskand@entrypointdecorators for an imperative programming style.
-
Install dependencies:
uv sync --group langgraph
This installs the standalone
temporalio-langgraphandtemporalio-langsmithpackages, which require Temporal 1.34.0 or later. -
Start a local dev server with the Temporal CLI:
temporal server start-dev
Most samples have two scripts -- start the Worker first, then the Workflow starter in a separate terminal.
# Terminal 1: start the Worker
uv run langgraph_plugin/<api>/<sample>/run_worker.py
# Terminal 2: start the Workflow
uv run langgraph_plugin/<api>/<sample>/run_workflow.pyFor example, to run the Graph API human-in-the-loop chatbot:
# Terminal 1
uv run langgraph_plugin/graph_api/human_in_the_loop/run_worker.py
# Terminal 2
uv run langgraph_plugin/graph_api/human_in_the_loop/run_workflow.pyThe LangSmith Tracing samples bundle the Worker and Workflow execution into a single main.py:
uv run langgraph_plugin/<api>/langsmith_tracing/main.py- Durable execution -- Every graph node /
@taskruns in a Workflow or as a Temporal activity with configurable timeouts and retry policies. - Human-in-the-loop -- LangGraph's
interrupt()pauses the graph; Temporal signals deliver human input; queries expose pending state to UIs. - Continue-as-new with caching --
cache()captures completed task results; passing the cache to the next execution avoids re-running them. - Conditional routing -- Graph API's
add_conditional_edgesand Functional API's nativeif/else/whilefor agent loops. - Parallel execution -- Functional API launches multiple tasks concurrently by creating futures before awaiting them.
- Streaming -- Workflow Streams expose a durable, offset-addressed event channel that external clients subscribe to while the workflow is still running. Nodes emit fine-grained tokens via
get_stream_writer()(routed by the plugin'sstreaming_topic), and the workflow can publish coarseastreamprogress to its own topic.
