Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
25e5fed
feat: align put, put_writes and get_tuple to redis checkpoint saver f…
CasperGN Nov 21, 2025
8565cd0
chore: include new import of python-ulid for langgraph checkpoint sup…
CasperGN Nov 21, 2025
7460439
chore: ruff formatting
CasperGN Nov 21, 2025
347f2f0
fix: include missing import of msgpack
CasperGN Nov 21, 2025
2650eb9
fix: ensure handing of empty checkpoint_id passed in config to put_wr…
CasperGN Nov 21, 2025
e78fa71
chore: align extract of config between put and put_writes
CasperGN Nov 21, 2025
128dac1
fix: handle str retrieval for get_tuple with extra type checking
CasperGN Nov 22, 2025
70851c5
chore: add example for ext-langgraph
CasperGN Nov 22, 2025
4d1f7d9
fix: rename to redis-memory
CasperGN Nov 22, 2025
d70a3d7
feat: add sqlite component
CasperGN Nov 22, 2025
4552630
fix: remove refs to redis
CasperGN Nov 22, 2025
7869a64
chore: update readme with details on dual state component setup
CasperGN Nov 22, 2025
2479e64
fix: add guard for None metadata
CasperGN Nov 23, 2025
8eed645
test: update test case to handle new output format
CasperGN Nov 23, 2025
5631206
chore: remove redundant graph .compile() call
CasperGN Nov 24, 2025
3ce65c1
fix: remove statestores and rely on existing metadata created
CasperGN Nov 25, 2025
5a3b3d5
fix: delete files not needed to align with ci testing
CasperGN Nov 25, 2025
2d150eb
fix: rename to agent.py & simplify
CasperGN Nov 25, 2025
e540817
chore: align deps
CasperGN Nov 25, 2025
4aeb74c
fix: correct readme to align with other examples
CasperGN Nov 25, 2025
b846604
chore: add extra validation lines
CasperGN Nov 25, 2025
3548b5f
feat: add langgraph-checkpointer to test
CasperGN Nov 25, 2025
ba9ac96
chore: ruff formatting
CasperGN Nov 25, 2025
cc67ef3
fix: add instruction for the OPENAI_API_KEY export
CasperGN Nov 25, 2025
af87f0b
Merge branch 'main' into feat/ext-langgraph-checkpoint
CasperGN Nov 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions examples/langgraph-checkpointer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Dapr For Agents - LangGraph Checkpointer

Supporting Dapr backed Checkpointer for LangGraph based Agents.

## Pre-requisites

- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started)
- [Install Python 3.10+](https://www.python.org/downloads/)

## Install Dapr python-SDK

<!-- Our CI/CD pipeline automatically installs the correct version, so we can skip this step in the automation -->

```bash
pip3 install -r requirements.txt
```

## Run the example

Export your `OPENAI_API_KEY`:

```bash
export OPENAI_API_KEY="SK-..."
```

Run the following command in a terminal/command prompt:

<!-- STEP
name: Run subscriber
expected_stdout_lines:
- '== APP == Add 3 and 4.'
- '== APP == Tool Calls:'
- '== APP == add'
- '== APP == Call'
- '== APP == a: 3'
- '== APP == b: 4'
- '== APP == Name: add'
- '== APP == 7'
- '== APP == The result of adding 3 and 4 is 7.'
- '== APP == Multiply that by 2.'
- '== APP == Args:'
- '== APP == a: 7'
- '== APP == b: 2'
- '== APP == ================================= Tool Message ================================='
- '== APP == Name: multiply'
- '== APP == '
- '== APP == 14'
- '== APP == ================================== Ai Message =================================='
- '== APP == '
- '== APP == The result of multiplying 7 by 2 is 14.'

output_match_mode: substring
background: true
match_order: none
sleep: 15
-->

```bash
# 1. Run the LangGraph agent
dapr run --app-id langgraph-checkpointer --app-port 5001 -- python3 agent.py
```

<!-- END_STEP -->

## Cleanup

Either press CTRL + C to quit the app or run the following command in a new terminal to stop the app:

```bash
dapr stop --app-id langgraph-checkpointer
```

68 changes: 68 additions & 0 deletions examples/langgraph-checkpointer/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import os

from dapr.ext.langgraph import DaprCheckpointer
from langchain_core.messages import HumanMessage, SystemMessage
from langchain_openai import ChatOpenAI
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


def multiply(a: int, b: int) -> int:
"""Multiply a and b.

Args:
a: first int
b: second int
"""
return a * b


tools = [add, multiply]
llm = ChatOpenAI(model='gpt-4o', api_key=os.environ['OPENAI_API_KEY'])
llm_with_tools = llm.bind_tools(tools)

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()

messages = [HumanMessage(content='Multiply that by 2.')]
messages = react_graph_memory.invoke({'messages': messages}, config)
for m in messages['messages']:
m.pretty_print()
5 changes: 5 additions & 0 deletions examples/langgraph-checkpointer/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
langchain-core>=1.0.7
langchain-openai>=1.0.3
langgraph>=1.0.3
dapr-ext-workflow>=1.16.0.dev
dapr>=1.16.0.dev
Loading