Conversation
Seven samples demonstrating the Temporal LangGraph plugin across both the Graph API and Functional API: - Human-in-the-loop: interrupt() + Temporal signals for chatbot approval - Continue-as-new: task result caching across workflow boundaries - ReAct agent: tool-calling loop with conditional edges / while loop - Control flow (Functional API only): parallel, for-loop, if/else Related SDK PR: temporalio/sdk-python#1448
|
|
… merge) so that CI otherwise passes
There was a problem hiding this comment.
Pull request overview
Adds a new langgraph_plugin/ sample suite to demonstrate running LangGraph workflows as durable Temporal workflows via the Temporal LangGraph plugin, covering both LangGraph Graph API and Functional API patterns.
Changes:
- Introduces 7 new LangGraph+Temporal sample workflows (human-in-the-loop, continue-as-new w/ caching, ReAct agent, control-flow).
- Adds a new
langgraphdependency group and includeslanggraph_pluginin the build packages list. - Updates repository documentation to link to the new sample suite and provides a dedicated README for running the samples.
Reviewed changes
Copilot reviewed 24 out of 34 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Adds langgraph dependency group, includes langgraph_plugin in wheel packages, adjusts lint/test tasks, and adds mypy override. |
| README.md | Links the new langgraph_plugin samples from the repo root README. |
| langgraph_plugin/README.md | Adds usage documentation and a sample matrix for the new suite. |
| langgraph_plugin/init.py | Declares the new top-level sample package. |
| langgraph_plugin/graph_api/init.py | Declares Graph API samples namespace. |
| langgraph_plugin/graph_api/react_agent/init.py | Declares Graph API ReAct agent package. |
| langgraph_plugin/graph_api/react_agent/workflow.py | Implements Graph API ReAct agent workflow and graph definition. |
| langgraph_plugin/graph_api/react_agent/run_worker.py | Worker wiring for Graph API ReAct agent sample. |
| langgraph_plugin/graph_api/react_agent/run_workflow.py | Starter script for Graph API ReAct agent sample. |
| langgraph_plugin/graph_api/human_in_the_loop/init.py | Declares Graph API human-in-the-loop package. |
| langgraph_plugin/graph_api/human_in_the_loop/workflow.py | Implements Graph API interrupt + Temporal signal/query human approval flow. |
| langgraph_plugin/graph_api/human_in_the_loop/run_worker.py | Worker wiring for Graph API human-in-the-loop sample. |
| langgraph_plugin/graph_api/human_in_the_loop/run_workflow.py | Starter script for Graph API human-in-the-loop sample. |
| langgraph_plugin/graph_api/continue_as_new/init.py | Declares Graph API continue-as-new package. |
| langgraph_plugin/graph_api/continue_as_new/workflow.py | Implements Graph API pipeline w/ continue-as-new + cache handoff. |
| langgraph_plugin/graph_api/continue_as_new/run_worker.py | Worker wiring for Graph API continue-as-new sample. |
| langgraph_plugin/graph_api/continue_as_new/run_workflow.py | Starter script for Graph API continue-as-new sample. |
| langgraph_plugin/functional_api/init.py | Declares Functional API samples namespace. |
| langgraph_plugin/functional_api/react_agent/init.py | Declares Functional API ReAct agent package. |
| langgraph_plugin/functional_api/react_agent/workflow.py | Implements Functional API ReAct agent via @task + @entrypoint. |
| langgraph_plugin/functional_api/react_agent/run_worker.py | Worker wiring for Functional API ReAct agent sample. |
| langgraph_plugin/functional_api/react_agent/run_workflow.py | Starter script for Functional API ReAct agent sample. |
| langgraph_plugin/functional_api/human_in_the_loop/init.py | Declares Functional API human-in-the-loop package. |
| langgraph_plugin/functional_api/human_in_the_loop/workflow.py | Implements Functional API interrupt + signal/query human approval flow. |
| langgraph_plugin/functional_api/human_in_the_loop/run_worker.py | Worker wiring for Functional API human-in-the-loop sample. |
| langgraph_plugin/functional_api/human_in_the_loop/run_workflow.py | Starter script for Functional API human-in-the-loop sample. |
| langgraph_plugin/functional_api/control_flow/init.py | Declares Functional API control-flow package. |
| langgraph_plugin/functional_api/control_flow/workflow.py | Implements Functional API sample demonstrating parallelism + branching. |
| langgraph_plugin/functional_api/control_flow/run_worker.py | Worker wiring for Functional API control-flow sample. |
| langgraph_plugin/functional_api/control_flow/run_workflow.py | Starter script for Functional API control-flow sample. |
| langgraph_plugin/functional_api/continue_as_new/init.py | Declares Functional API continue-as-new package. |
| langgraph_plugin/functional_api/continue_as_new/workflow.py | Implements Functional API pipeline w/ continue-as-new + cache handoff. |
| langgraph_plugin/functional_api/continue_as_new/run_worker.py | Worker wiring for Functional API continue-as-new sample. |
| langgraph_plugin/functional_api/continue_as_new/run_workflow.py | Starter script for Functional API continue-as-new sample. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Combines LangGraphPlugin (durable execution) with LangSmithPlugin (observability) for full tracing of LLM calls through Temporal workflows.
| @@ -0,0 +1,41 @@ | |||
| # LangSmith Tracing (Functional API) | |||
|
|
|||
| Same pattern as the Graph API version, using `@task` and `@entrypoint` decorators. | |||
There was a problem hiding this comment.
I assume people are either using Graph API or Functional API and not both. If that's true, we should probably avoid referencing one from the other since a user of the Functional API probably doesn't care about looking at Graph API examples.
| # Terminal 1 | ||
| uv run langgraph_plugin/functional_api/langsmith_tracing/run_worker.py | ||
|
|
||
| # Terminal 2 | ||
| uv run langgraph_plugin/functional_api/langsmith_tracing/run_workflow.py |
There was a problem hiding this comment.
Do we want to get in the habit of running these in the same python file to reduce the number of steps needed to get started?
| |------|-------------| | ||
| | `workflow.py` | `@traceable` chat task, `@entrypoint`, and `ChatFunctionalWorkflow` | | ||
| | `run_worker.py` | Creates client with `LangSmithPlugin`, worker with `LangGraphPlugin` | | ||
| | `run_workflow.py` | Creates client with `LangSmithPlugin`, executes workflow | |
|
|
||
| from datetime import timedelta | ||
|
|
||
| from langgraph.func import entrypoint as lg_entrypoint |
There was a problem hiding this comment.
This naming collision is a bit of a pain point that comes up 100% of the time when using the Functional API. I wonder if we want our plugin to provide temporal_entrypoint and temporal_graph to avoid this issue.
|
|
||
|
|
||
| @task | ||
| @traceable(name="chat_task", run_type="chain") |
There was a problem hiding this comment.
We should also demonstrate wrapping traceables around functions inside the task/Activity and around functions inside the entrypoint/Workflow. Right now we're only covering 1/3 use cases.
| t.func.__name__: {"start_to_close_timeout": timedelta(seconds=30)} | ||
| for t in all_tasks |
There was a problem hiding this comment.
for loop not needed since there's only one task
|
|
||
| ## Running the Sample | ||
|
|
||
| Prerequisites: `uv sync --group langgraph` and a running Temporal dev server. |
There was a problem hiding this comment.
Type out temporal server start-dev here?
|
|
||
| ## What This Sample Demonstrates | ||
|
|
||
| - Task result caching across continue-as-new boundaries with `get_cache()` |
There was a problem hiding this comment.
Rename to cache() to match graph() and entrypoint()
|
|
||
| ## How It Works | ||
|
|
||
| 1. Three tasks run sequentially: `extract` (x2) -> `transform` (+50) -> `load` (x3). |
There was a problem hiding this comment.
This is a bit weird. My first thought is why is a x2 operation called "extract"? Maybe we want to rename it or actually do an ETL-like pipeline
Summary
Add samples demonstrating the Temporal LangGraph plugin, which runs LangGraph workflows as durable Temporal workflows. Each graph node or
@taskexecutes as a Temporal activity with automatic retries, timeouts, and crash recovery.Samples are provided for both the Graph API (declarative
StateGraphwith nodes and edges) and the Functional API (imperative@task/@entrypointdecorators).interrupt()to pause for human approval, Temporal signals to receive feedback, and queries to expose the pending draft.continue-as-newwith task result caching so previously-completed stages are not re-executed.add_conditional_edges; Functional API uses awhileloop.forloops, andif/elsebranching — patterns that are natural in the Functional API.LangGraphPluginwith Temporal'sLangSmithPluginfor durable execution + full LLM observability. Requires API keys.Key Features Demonstrated
@taskruns as a Temporal activity with configurable timeouts and retry policies.interrupt()pauses the graph; Temporal signals deliver human input; queries expose pending state to UIs.get_cache()captures completed task results; passing the cache to the next execution avoids re-running them.add_conditional_edgesand Functional API's nativeif/else/whilefor agent loops.LangSmithPluginon the client +LangGraphPluginon the worker for full trace propagation through Temporal workflows.Related PRs
Test plan
uv run langgraph_plugin/<api>/<sample>/run_worker.py+run_workflow.pyANTHROPIC_API_KEYandLANGCHAIN_API_KEY