crewai-persistence-dynamodb
Amazon DynamoDB persistence backend for CrewAI Flows. Persists flow state across runs, with optional built-in message pruning via agentstate-reducer.
Implements CrewAI's FlowPersistence interface, so it drops straight into the @persist decorator.
Installation
pip install crewai-persistence-dynamodb
# with message pruning:
pip install "crewai-persistence-dynamodb[reducer]"
Requires Python 3.10–3.13 (matches CrewAI's supported range).
Usage
from crewai.flow.flow import Flow, start
from crewai.flow.persistence import persist
from crewai_persistence_dynamodb import DynamoDBFlowPersistence
backend = DynamoDBFlowPersistence(table_name="crewai-flows", region_name="us-east-1")
@persist(backend)
class MyFlow(Flow[MyState]):
@start()
def begin(self):
self.state.counter += 1
The table is auto-created (on-demand billing) if it doesn't exist, keyed by flow_uuid.
With message pruning (conversational flows)
from agentstate_reducer import MessageReducer
from crewai_persistence_dynamodb import DynamoDBFlowPersistence
backend = DynamoDBFlowPersistence(
table_name="crewai-flows",
reducer=MessageReducer(min_messages=10, max_messages=20),
messages_key="messages", # state field holding the message list
)
API
DynamoDBFlowPersistence(table_name, *, region_name=None, boto_session=None, endpoint_url=None, ttl_seconds=None, reducer=None, messages_key="messages")
| Parameter | Description |
|---|---|
table_name |
DynamoDB table (auto-created if absent) |
region_name |
AWS region |
boto_session |
Optional pre-built boto3.Session |
endpoint_url |
Custom endpoint (DynamoDB Local / LocalStack) |
ttl_seconds |
If set, flow state expires automatically via a ttl attribute |
reducer |
Optional MessageReducer to prune messages_key before each save |
messages_key |
State field holding the message list (default "messages") |
Authentication
Standard boto3 credential resolution — env vars, ~/.aws/credentials, AWS_PROFILE, SSO, or IAM roles. Needs permission to create the table (if absent) and read/write items.
Data model
One item per flow, keyed by flow_uuid. The flow state is stored as a JSON string in a data attribute; method_name and saved_at are stored alongside as metadata. Each save upserts, so load_state returns the latest state.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file crewai_persistence_dynamodb-0.1.0.tar.gz.
File metadata
- Download URL: crewai_persistence_dynamodb-0.1.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2094adae5ffde236f60758e1a57acec804d7354470b02cac9a77ae3095d0ac9
|
|
| MD5 |
0a141d1f1c9ac8e10c6c9b66114f6cf9
|
|
| BLAKE2b-256 |
1870441a2a028809e2c1a788b7ba684a04ddd0e37e1196d4fb1f6e66d7951ec4
|
File details
Details for the file crewai_persistence_dynamodb-0.1.0-py3-none-any.whl.
File metadata
- Download URL: crewai_persistence_dynamodb-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea74065cfc8ad6962013f701e551b3a25e205050ca72a7979a0ddb4bba8f2ffc
|
|
| MD5 |
fecbb4b670a68911f4033e4889289856
|
|
| BLAKE2b-256 |
d0f169ead0b9c81fe8b140ff860b7bf346cb6a0e2645ca75e81c06b32bde7bfb
|