Commit 601f5d4
authored
[AI-72] LangGraph plugin samples (#289)
* Add LangGraph plugin samples
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
* Remove explicit langchain deps from langgraph group to avoid conflict
* Declare langchain and langgraph as conflicting dependency groups
* Fix import sorting and formatting
* Update dependencies and lint config (temporarily - waiting for SDK PR merge) so that CI otherwise passes
* Add hello_world samples, per-sample READMEs, tests, __init__ docstrings, and configurable client
* Address review: consistent v2 API, unique thread_id, SDK prereq note
* Remove SDK prereq note - PR won't merge until plugin is released
* Add LangSmith tracing sample (Graph API + Functional API)
Combines LangGraphPlugin (durable execution) with LangSmithPlugin
(observability) for full tracing of LLM calls through Temporal workflows.
* Update all samples to match SDK PR #1448 API
- graphs parameter is now a list, not a dict
- No graph()/entrypoint() lookup functions — reference objects directly
- No entrypoints parameter on LangGraphPlugin
- Use set_cache()/get_cache() for continue-as-new caching
- Update tests and READMEs accordingly
* Update LangGraph samples to current sdk-python main API
The plugin API has evolved past PR #1448:
- LangGraphPlugin(graphs=...) now takes dict[str, StateGraph], not list
- Same for entrypoints (dict[str, Pregel])
- Each node/task must declare execute_in: "activity" | "workflow" in metadata
- Workflows look up registered graphs/entrypoints via graph(name) /
entrypoint(name) instead of importing them directly
- get_cache/set_cache replaced by cache() and graph(name, cache=...) /
entrypoint(name, cache=...)
Other changes:
- State schemas converted from primitives (str, int) to TypedDict, since
langgraph's StateT is bound to TypedDict / dataclass / pydantic models
- Module-level graph instances replaced with make_<name>_graph() factories
because LangGraphPlugin mutates node metadata in-place at construction
time, which prevented reuse across tests
- langgraph dep group now pulls langchain, langchain-anthropic, and
temporalio[langgraph,langsmith] so the langsmith_tracing samples and
human_in_the_loop's RunnableConfig usage actually resolve
* CI: install protoc for building temporalio from sdk-python git source
* Skip LangGraph functional API + interrupt tests on Python < 3.11
These features rely on contextvars propagation through asyncio.create_task(),
which is only available in Python 3.11+. On 3.10 they hang rather than fail
cleanly, so CI sat for an hour before today's fix landed.
Mirrors the pytestmark skipif used in sdk-python's own contrib/langgraph
tests.
* Address review feedback on LangGraph samples
- Drop cross-references between Functional API and Graph API READMEs so
each stands alone (review comment 1)
- Combine run_worker.py + run_workflow.py into a single main.py for the
langsmith_tracing samples to reduce setup steps (review comment 2)
- Fix workflow -> Workflow casing (review comment 3)
- Alias temporalio's entrypoint and graph helpers as temporal_entrypoint /
temporal_graph at import sites to avoid the langgraph.func.entrypoint
collision (review comment 4)
- Demonstrate @Traceable in three places in both langsmith_tracing samples:
on the Activity/task itself, on a helper called from the Activity, and
on a helper called from the Workflow (review comment 5)
- Drop unnecessary single-task list comprehension for activity_options in
hello_world and langsmith_tracing functional samples (review comment 6)
- Spell out 'temporal server start-dev' in every sample README's
prerequisites (review comment 7)
- Fix stale README references to get_cache() now that the API is cache()
(review comment 8)
- Rename arbitrarily-named ETL pipeline functions in continue_as_new to
honest math names (double / add_50 / triple) per review comment 9
* Update LangGraph samples for temporalio 1.27.0 release
- Drop the [tool.uv.sources] git pin; consume temporalio from PyPI now
that 1.27.0 ships the LangGraph plugin.
- Keep the protoc CI step around as a permanent fixture so we don't have
to add and remove it each time we iterate on a new plugin sample.
- Replace dict-comprehension activity_options with explicit per-task
literals in the Functional API samples.
- Emphasize workflow.wait_condition() in the human-in-the-loop READMEs
as the durable wait primitive that pairs with interrupt() and signals.
- Clarify that the task result cache is provided by the LangGraph plugin
(Temporal), not by upstream LangGraph.
- Drop "Same pattern as the Graph API version" cross-references from
Functional API workflow docstrings; readers pick one API style.
- Tighten the Functional API LangSmith tracing README copy.
- Point the parent README to the released contrib package docs.1 parent 6b8e441 commit 601f5d4
71 files changed
Lines changed: 2873 additions & 92 deletions
File tree
- .github/workflows
- langgraph_plugin
- functional_api
- continue_as_new
- control_flow
- hello_world
- human_in_the_loop
- langsmith_tracing
- react_agent
- graph_api
- continue_as_new
- hello_world
- human_in_the_loop
- langsmith_tracing
- react_agent
- tests/langgraph_plugin
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
36 | 44 | | |
37 | 45 | | |
38 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
Lines changed: 92 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
0 commit comments