From fd05009be24d6dbec0ede7f07f429ec0487b548b Mon Sep 17 00:00:00 2001 From: Casper Nielsen Date: Tue, 25 Nov 2025 13:17:06 +0100 Subject: [PATCH 01/11] feat: add dapr-ext-langgraph documentation Signed-off-by: Casper Nielsen --- .../python-sdk-extensions/python-langgraph.md | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md diff --git a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md new file mode 100644 index 00000000000..22b49390ee7 --- /dev/null +++ b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md @@ -0,0 +1,72 @@ +--- +type: docs +title: "Dapr Python SDK integration with LangGraph" +linkTitle: "LangGraph" +weight: 500000 +description: How to let Dapr handle LangGraph Checkpointer (Memory) +--- + +The Dapr Python SDK provides integration with LangGraph Checkpointer using the `dapr-ext-langgraph` extension. + +## Installation + +You can download and install the Dapr LangGraph extension with: + +{{< tabpane text=true >}} + +{{% tab header="Stable" %}} + +```bash +pip install dapr-ext-langgraph +``` + +{{% /tab %}} + +{{% tab header="Development" %}} +{{% alert title="Note" color="warning" %}} +The development package will contain features and behavior that will be compatible with the pre-release version of the Dapr runtime. Make sure to uninstall any stable versions of the Python SDK extension before installing the `dapr-dev` package. +{{% /alert %}} + +```bash +pip install dapr-ext-langgraph-dev +``` + +{{% /tab %}} + +{{< /tabpane >}} + +## Example + +### Setting DaprCheckPointer + +To let Dapr handle the checkpointer (memory in LangGraph) you only need to utilize the `DaprCheckpointer` as the checkpointer object when compiling the graph. Given the below Component for redis State Manager: + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: statestore +spec: + type: state.redis + version: v1 + metadata: + - name: redisHost + value: localhost:6379 +``` + +You then pass the checkpointer just like any other checkpointer provider: + +```python +from langgraph.graph import StateGraph, MessageState +from dapr.ext.langgraph import DaprCheckpointer + +# Build the graph with nodes and edges +builder = StateGraph(MessagesState) + +memory = DaprCheckpointer(store_name='statestore', key_prefix='dapr') +graph = builder.compile(checkpointer=memory) +``` + +For a full working example refer to the [langgraph example](). + +For available State Managers refer to the [supported state stores](https://docs.dapr.io/reference/components-reference/supported-state-stores/). From 928f98654d7c391c2b796f9e29cc3e51b022e951 Mon Sep 17 00:00:00 2001 From: Casper Nielsen Date: Tue, 25 Nov 2025 13:27:46 +0100 Subject: [PATCH 02/11] fix: remove link to state stores Signed-off-by: Casper Nielsen --- .../python-sdk-docs/python-sdk-extensions/python-langgraph.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md index 22b49390ee7..5550178a6c5 100644 --- a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md +++ b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md @@ -68,5 +68,3 @@ graph = builder.compile(checkpointer=memory) ``` For a full working example refer to the [langgraph example](). - -For available State Managers refer to the [supported state stores](https://docs.dapr.io/reference/components-reference/supported-state-stores/). From 7fa62166c2a336ca7d11c88ad98cfdb9c2c7f1ca Mon Sep 17 00:00:00 2001 From: Casper Nielsen Date: Tue, 25 Nov 2025 14:26:41 +0100 Subject: [PATCH 03/11] fix: remove redundant header & wording correction Signed-off-by: Casper Nielsen --- .../python-sdk-docs/python-sdk-extensions/python-langgraph.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md index 5550178a6c5..05f6d03072c 100644 --- a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md +++ b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md @@ -37,8 +37,6 @@ pip install dapr-ext-langgraph-dev ## Example -### Setting DaprCheckPointer - To let Dapr handle the checkpointer (memory in LangGraph) you only need to utilize the `DaprCheckpointer` as the checkpointer object when compiling the graph. Given the below Component for redis State Manager: ```yaml @@ -67,4 +65,4 @@ memory = DaprCheckpointer(store_name='statestore', key_prefix='dapr') graph = builder.compile(checkpointer=memory) ``` -For a full working example refer to the [langgraph example](). +For a full example refer to the [langgraph example](). From 993721f1a7da9592466d9525fc87e3a535e95a3f Mon Sep 17 00:00:00 2001 From: Casper Nielsen Date: Tue, 16 Dec 2025 10:58:14 +0100 Subject: [PATCH 04/11] fix: add missing link Signed-off-by: Casper Nielsen --- .../python-sdk-docs/python-sdk-extensions/python-langgraph.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md index 05f6d03072c..880e4c270d5 100644 --- a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md +++ b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md @@ -65,4 +65,4 @@ memory = DaprCheckpointer(store_name='statestore', key_prefix='dapr') graph = builder.compile(checkpointer=memory) ``` -For a full example refer to the [langgraph example](). +For a full example refer to the [langgraph example](https://github.com/dapr/python-sdk/tree/main/examples/langgraph-checkpointer). From 70901db2fc6f2b2c719990ccce64a13a6e23e93c Mon Sep 17 00:00:00 2001 From: Casper Nielsen Date: Tue, 16 Dec 2025 14:43:01 +0100 Subject: [PATCH 05/11] Update sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md Co-authored-by: Marc Duiker Signed-off-by: Casper Nielsen --- .../python-sdk-docs/python-sdk-extensions/python-langgraph.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md index 880e4c270d5..4cf3e314d39 100644 --- a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md +++ b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md @@ -10,7 +10,7 @@ The Dapr Python SDK provides integration with LangGraph Checkpointer using the ` ## Installation -You can download and install the Dapr LangGraph extension with: +Download and install the Dapr LangGraph extension with: {{< tabpane text=true >}} From 2a79ad45bff20a186e74976f8a3733c5ddee9ae1 Mon Sep 17 00:00:00 2001 From: Casper Nielsen Date: Tue, 16 Dec 2025 14:43:09 +0100 Subject: [PATCH 06/11] Update sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md Co-authored-by: Marc Duiker Signed-off-by: Casper Nielsen --- .../python-sdk-docs/python-sdk-extensions/python-langgraph.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md index 4cf3e314d39..1181dc7e418 100644 --- a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md +++ b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md @@ -52,7 +52,7 @@ spec: value: localhost:6379 ``` -You then pass the checkpointer just like any other checkpointer provider: +Pass the checkpointer just like any other checkpointer provider: ```python from langgraph.graph import StateGraph, MessageState From 3cc2dd1cf27732901ee7ce77e2930516fbdf83de Mon Sep 17 00:00:00 2001 From: Casper Nielsen Date: Tue, 16 Dec 2025 14:43:26 +0100 Subject: [PATCH 07/11] Update sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md Co-authored-by: Marc Duiker Signed-off-by: Casper Nielsen --- .../python-sdk-docs/python-sdk-extensions/python-langgraph.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md index 1181dc7e418..2d55a9d77a6 100644 --- a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md +++ b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md @@ -65,4 +65,4 @@ memory = DaprCheckpointer(store_name='statestore', key_prefix='dapr') graph = builder.compile(checkpointer=memory) ``` -For a full example refer to the [langgraph example](https://github.com/dapr/python-sdk/tree/main/examples/langgraph-checkpointer). +For a full example refer to this [langgraph example](https://github.com/dapr/python-sdk/tree/main/examples/langgraph-checkpointer) in the Dapr Python SDK repository. From 7fcac0376997e7cecf6d5c7e42543df79fef9c83 Mon Sep 17 00:00:00 2001 From: Casper Nielsen Date: Tue, 16 Dec 2025 14:43:45 +0100 Subject: [PATCH 08/11] Update sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md Co-authored-by: Marc Duiker Signed-off-by: Casper Nielsen --- .../python-sdk-docs/python-sdk-extensions/python-langgraph.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md index 2d55a9d77a6..f493c7e3cd5 100644 --- a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md +++ b/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md @@ -37,7 +37,7 @@ pip install dapr-ext-langgraph-dev ## Example -To let Dapr handle the checkpointer (memory in LangGraph) you only need to utilize the `DaprCheckpointer` as the checkpointer object when compiling the graph. Given the below Component for redis State Manager: +To let Dapr handle the checkpointer (memory in LangGraph) utilize the `DaprCheckpointer` as the checkpointer object when compiling the graph. Given the following Redis state store component: ```yaml apiVersion: dapr.io/v1alpha1 From 6a12e0fff0cc8e91e5c72f818877f3b78240707c Mon Sep 17 00:00:00 2001 From: Casper Nielsen Date: Wed, 17 Dec 2025 09:38:36 +0100 Subject: [PATCH 09/11] docs: move langgraph memory documentation into new ai docs structure Signed-off-by: Casper Nielsen --- .../agent-integrations/langgraph/_index.md | 11 +++++++++++ .../langgraph/langgraph-agents-sessions.md | 16 +++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 daprdocs/content/en/developing-ai/agent-integrations/langgraph/_index.md rename sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md => daprdocs/content/en/developing-ai/agent-integrations/langgraph/langgraph-agents-sessions.md (80%) diff --git a/daprdocs/content/en/developing-ai/agent-integrations/langgraph/_index.md b/daprdocs/content/en/developing-ai/agent-integrations/langgraph/_index.md new file mode 100644 index 00000000000..c427457c95f --- /dev/null +++ b/daprdocs/content/en/developing-ai/agent-integrations/langgraph/_index.md @@ -0,0 +1,11 @@ +--- +type: docs +title: "LangGraph" +linkTitle: "LangGraph" +weight: 25 +description: "Dapr first-class integrations with LangGraph Agents" +--- + +### What is the Dapr LangGraph integration? + +Dapr provides LangGraph agents a first class integration to agent session management (checkpointers). diff --git a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md b/daprdocs/content/en/developing-ai/agent-integrations/langgraph/langgraph-agents-sessions.md similarity index 80% rename from sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md rename to daprdocs/content/en/developing-ai/agent-integrations/langgraph/langgraph-agents-sessions.md index f493c7e3cd5..a1d35dc6bfd 100644 --- a/sdkdocs/python/content/en/python-sdk-docs/python-sdk-extensions/python-langgraph.md +++ b/daprdocs/content/en/developing-ai/agent-integrations/langgraph/langgraph-agents-sessions.md @@ -2,13 +2,23 @@ type: docs title: "Dapr Python SDK integration with LangGraph" linkTitle: "LangGraph" -weight: 500000 -description: How to let Dapr handle LangGraph Checkpointer (Memory) +weight: 30 +description: "How to use Dapr reliably and securely manage LangGraph Agent Checkpointers" --- +## Overview + The Dapr Python SDK provides integration with LangGraph Checkpointer using the `dapr-ext-langgraph` extension. -## Installation +## Getting Started + +### Install Python + +{{% alert title="Note" color="info" %}} +Make sure you have Python already installed. `Python >=3.10`. For installation instructions, visit the official [Python installation guide](https://www.python.org/downloads/). +{{% /alert %}} + +### Download Dependencies Download and install the Dapr LangGraph extension with: From 939ce89d5e551e3ef56b16b29d4078da4a9021e3 Mon Sep 17 00:00:00 2001 From: Casper Nielsen Date: Wed, 17 Dec 2025 09:53:50 +0100 Subject: [PATCH 10/11] chore: align naming across all third party agent frameworks Signed-off-by: Casper Nielsen --- .../developing-ai/agent-integrations/openai-agents/_index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/daprdocs/content/en/developing-ai/agent-integrations/openai-agents/_index.md b/daprdocs/content/en/developing-ai/agent-integrations/openai-agents/_index.md index 83d119d11d3..85fd5e20c5e 100644 --- a/daprdocs/content/en/developing-ai/agent-integrations/openai-agents/_index.md +++ b/daprdocs/content/en/developing-ai/agent-integrations/openai-agents/_index.md @@ -1,7 +1,7 @@ --- type: docs -title: "OpenAI Agents" -linkTitle: "OpenAI Agents" +title: "OpenAI" +linkTitle: "OpenAI" weight: 25 description: "Dapr first-class integrations for OpenAI Agents" --- From 3779b4c61ba569eb38fbe1dbfc3c9c99f20e7474 Mon Sep 17 00:00:00 2001 From: Casper Nielsen Date: Wed, 17 Dec 2025 09:54:42 +0100 Subject: [PATCH 11/11] docs: align document structure to openai example Signed-off-by: Casper Nielsen --- .../langgraph/langgraph-agents-sessions.md | 109 +++++++++++++++--- 1 file changed, 90 insertions(+), 19 deletions(-) diff --git a/daprdocs/content/en/developing-ai/agent-integrations/langgraph/langgraph-agents-sessions.md b/daprdocs/content/en/developing-ai/agent-integrations/langgraph/langgraph-agents-sessions.md index a1d35dc6bfd..aa78693b707 100644 --- a/daprdocs/content/en/developing-ai/agent-integrations/langgraph/langgraph-agents-sessions.md +++ b/daprdocs/content/en/developing-ai/agent-integrations/langgraph/langgraph-agents-sessions.md @@ -1,7 +1,7 @@ --- type: docs -title: "Dapr Python SDK integration with LangGraph" -linkTitle: "LangGraph" +title: "Agent Sessions" +linkTitle: "Agent Sessions" weight: 30 description: "How to use Dapr reliably and securely manage LangGraph Agent Checkpointers" --- @@ -12,6 +12,20 @@ The Dapr Python SDK provides integration with LangGraph Checkpointer using the ` ## Getting Started +Initialize Dapr locally to set up a self-hosted environment for development. This process fetches and installs the Dapr sidecar binaries, runs essential services as Docker containers, and prepares a default components folder for your application. For detailed steps, see the official [guide on initializing Dapr locally]({{% ref install-dapr-cli.md %}}). + +To initialize the Dapr control plane containers and create a default configuration file, run: + +```bash +dapr init +``` + +Verify you have container instances with `daprio/dapr`, `openzipkin/zipkin`, and `redis` images running: + +```bash +docker ps +``` + ### Install Python {{% alert title="Note" color="info" %}} @@ -27,7 +41,7 @@ Download and install the Dapr LangGraph extension with: {{% tab header="Stable" %}} ```bash -pip install dapr-ext-langgraph +pip install dapr-ext-langgraph langchain_openai langchain_core langgraph langgraph-prebuilt ``` {{% /tab %}} @@ -38,16 +52,82 @@ The development package will contain features and behavior that will be compatib {{% /alert %}} ```bash -pip install dapr-ext-langgraph-dev +pip install dapr-ext-langgraph-dev langchain_openai langchain_core langgraph langgraph-prebuilt ``` {{% /tab %}} {{< /tabpane >}} -## Example +### Create a LangGraph Agent + +To let Dapr handle the agent memory, utilize the `DaprCheckpointer` as the checkpointer object when compiling the graph. Pass the checkpointer just like any other checkpointer provider: + +```python +from dapr.ext.langgraph import DaprCheckpointer +from langchain_openai import ChatOpenAI +from langchain_core.messages import HumanMessage, SystemMessage +from langgraph.graph import START, MessagesState, StateGraph +from langgraph.prebuilt import ToolNode, tools_condition + + +def add(a: int, b: int) -> int: + """Adds a and b. + + Args: + a: first int + b: second int + """ + return a + b + +tools = [add] +llm = ChatOpenAI(model="gpt-4o") +llm_with_tools = llm.bind_tools(tools) -To let Dapr handle the checkpointer (memory in LangGraph) utilize the `DaprCheckpointer` as the checkpointer object when compiling the graph. Given the following Redis state store component: +sys_msg = SystemMessage( + content='You are a helpful assistant tasked with performing arithmetic on a set of inputs.' +) + +def assistant(state: MessagesState): + return {'messages': [llm_with_tools.invoke([sys_msg] + state['messages'])]} + +builder = StateGraph(MessagesState) +builder.add_node('assistant', assistant) +builder.add_node('tools', ToolNode(tools)) +builder.add_edge(START, 'assistant') +builder.add_conditional_edges( + 'assistant', + tools_condition, +) +builder.add_edge('tools', 'assistant') + +memory = DaprCheckpointer(store_name='statestore', key_prefix='dapr') +react_graph_memory = builder.compile(checkpointer=memory) + +config = {'configurable': {'thread_id': '1'}} + +messages = [HumanMessage(content='Add 3 and 4.')] +messages = react_graph_memory.invoke({'messages': messages}, config) +for m in messages['messages']: + m.pretty_print() +``` + +### Set an OpenAI API key + +```bash +export OPENAI_API_KEY=sk-... +``` + +### Create a Python venv + +```bash +python -m venv .venv +source .venv/bin/activate # On Windows: .venv\Scripts\activate +``` + +## Create the database component + +The component file is how Dapr connects to your databae. The full list of supported databases can be found [here]({{% ref supported-state-stores %}}). Create a `components` directory and this file in it: ```yaml apiVersion: dapr.io/v1alpha1 @@ -60,19 +140,10 @@ spec: metadata: - name: redisHost value: localhost:6379 + - name: redisPassword + value: "" ``` -Pass the checkpointer just like any other checkpointer provider: - -```python -from langgraph.graph import StateGraph, MessageState -from dapr.ext.langgraph import DaprCheckpointer - -# Build the graph with nodes and edges -builder = StateGraph(MessagesState) - -memory = DaprCheckpointer(store_name='statestore', key_prefix='dapr') -graph = builder.compile(checkpointer=memory) -``` +## Next Steps -For a full example refer to this [langgraph example](https://github.com/dapr/python-sdk/tree/main/examples/langgraph-checkpointer) in the Dapr Python SDK repository. +Now that you have a LangGraph agent using Dapr to manage the agent sessions, explore more you can do with the [State API]({{% ref "state-management-overview" %}}) and how to enable [resiliency policies]({{% ref resiliency-overview %}}) for enhanced reliability.