strands-dynamodb-storage (Python)
Python implementation of the Amazon DynamoDB Storage backend for the Strands Agents SDK — at
parity with ../typescript/. Implements the SDK's strands.storage.Storage protocol
(write/read/delete/list, plus namespace) so one DynamoDB-backed instance serves Session
Manager, Memory Manager, and any subsystem that persists bytes.
Install
pip install strands-dynamodb-storage
Usage
from strands import Agent
from strands.session import SessionManager
from strands_dynamodb_storage import DynamoDBStorage
storage = DynamoDBStorage("agent-data", region_name="us-east-1")
agent = Agent(session_manager=SessionManager(storage=storage))
Direct byte usage (async):
store = DynamoDBStorage("agent-data", region_name="us-east-1")
await store.write("sessions/s1/snapshot.json", b'{"turn": 1}')
data = await store.read("sessions/s1/snapshot.json") # bytes | None
keys = await store.list("sessions/s1/") # native Query
# Note: prefixes must cover at least a full scope and identifier ("scope/id/").
# list("") and single-segment prefixes are rejected as too broad -- they would
# require a cross-partition Scan. This deliberately narrows the SDK Storage
# contract (whose in-memory backends list everything on ""); SDK subsystems
# always pass namespaced prefixes and are unaffected.
scoped = await store.list(DynamoDBListQuery(pk="sessions/s1", sk_prefix="scopes/"))
await store.delete("sessions/s1/snapshot.json")
Features (parity with the TypeScript package)
- Single-table design (
pk/sk), with a structuredDynamoDBListQueryextension point. - Optional Amazon S3 offload for values above the item-size limit (
s3_bucket=...). - Optional gzip
compression="gzip"(applied before the offload check). - Optional per-item TTL (
ttl_seconds=...) with read/list expiry filtering. - Native vector
search()via Amazon DynamoDB vector indexes (SearchVectors, requires boto3 >= 1.43.64); avector_searchadapter can override the call.
Semantic search
search() gives an agent semantic long-term memory over the same table: write each memory
with its embedding, then query by meaning. Scoring runs in the database against a DynamoDB
vector index (no second vector store, no ETL), and because the index is partitioned on pk,
every search is scoped to the caller's key space -- one tenant's memories can never surface
in another's results. Creating the table with a vector index (and the IAM permissions needed)
is covered in the repository README's Provisioning and permissions.
from strands_dynamodb_storage import DynamoDBStorage, SearchQuery
store = DynamoDBStorage("agent-memory", region_name="us-east-1", prefix="user/u1")
# store a memory with its embedding (kept inline even when the payload offloads to S3)
await store.write(
"memories/m1",
b"likes window seats",
vector=embed("likes window seats"), # your embedding model, e.g. 1024 floats
metadata={"kind": "preference"},
)
# recall by meaning, scoped to this store's partition
results = await store.search(SearchQuery(
vector=embed("seating preferences?"),
top_k=5,
pk="user/u1/memories", # required: the index declares a HASH element
filter={"kind": "preference"}, # optional metadata equality filter
include_values=True, # hydrate each match's stored bytes
))
for r in results:
print(r.key, r.score, r.data)
# ordered most-similar-first; score direction follows the index's distance function
# (COSINE/EUCLIDEAN: lower = nearer; DOT_PRODUCT: higher = more similar)
Like a global secondary index, the vector index is eventually consistent, and a freshly
created index backfills before it is searchable. Requires boto3 >= 1.43.64; a
vector_search adapter, when configured, overrides the native call (testing, custom routing).
Development
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/python -m pytest -q # unit tests (moto, offline)
.venv/bin/ruff check src tests && .venv/bin/mypy src
RUN_INTEG=1 AWS_REGION=us-east-1 .venv/bin/python -m pytest tests/integ -q # real DynamoDB + S3
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 strands_dynamodb_storage-0.1.0.tar.gz.
File metadata
- Download URL: strands_dynamodb_storage-0.1.0.tar.gz
- Upload date:
- Size: 23.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43ecce5eccf935f25ff3cd1d8e62b0221f2d86790ffdac64f994ea87192c346a
|
|
| MD5 |
ce20bd43d11d593506bfdbc5e82d6df5
|
|
| BLAKE2b-256 |
7e31a8de33a90b1a75fc9bbb999f2bccac6dc0f3bd65d832fd80c347a0cde9f5
|
Provenance
The following attestation bundles were made for strands_dynamodb_storage-0.1.0.tar.gz:
Publisher:
publish-python.yml on aws/strands-dynamodb-storage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
strands_dynamodb_storage-0.1.0.tar.gz -
Subject digest:
43ecce5eccf935f25ff3cd1d8e62b0221f2d86790ffdac64f994ea87192c346a - Sigstore transparency entry: 2466460349
- Sigstore integration time:
-
Permalink:
aws/strands-dynamodb-storage@64efaf0be41f23e54c325c4731dfbf6d8ce883a1 -
Branch / Tag:
refs/tags/python-v0.1.0 - Owner: https://github.com/aws
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@64efaf0be41f23e54c325c4731dfbf6d8ce883a1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file strands_dynamodb_storage-0.1.0-py3-none-any.whl.
File metadata
- Download URL: strands_dynamodb_storage-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4181e71773e3a0cd6b38568690ebb87baf76b5f9a084fcee6c6c79fff90331d
|
|
| MD5 |
bfde604c38f6a9c037171e7150d272cd
|
|
| BLAKE2b-256 |
450087bbd24e66b680808230af323a20d3aca00e3b6bb6649706746e43635b17
|
Provenance
The following attestation bundles were made for strands_dynamodb_storage-0.1.0-py3-none-any.whl:
Publisher:
publish-python.yml on aws/strands-dynamodb-storage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
strands_dynamodb_storage-0.1.0-py3-none-any.whl -
Subject digest:
d4181e71773e3a0cd6b38568690ebb87baf76b5f9a084fcee6c6c79fff90331d - Sigstore transparency entry: 2466460368
- Sigstore integration time:
-
Permalink:
aws/strands-dynamodb-storage@64efaf0be41f23e54c325c4731dfbf6d8ce883a1 -
Branch / Tag:
refs/tags/python-v0.1.0 - Owner: https://github.com/aws
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@64efaf0be41f23e54c325c4731dfbf6d8ce883a1 -
Trigger Event:
release
-
Statement type: