strands-postgres-store
A PostgreSQL + pgvector MemoryStore for Strands Agents — semantic long-term agent memory backed by native pgvector similarity search (the <=> cosine-distance operator over an HNSW index). No external vector database.
pip install strands-postgres-store
from strands import Agent
from strands.memory import MemoryManager
from strands_postgres_store import PostgresMemoryStore
store = PostgresMemoryStore(name="user-memories", url="postgresql://user:pass@localhost:5432/db")
agent = Agent(memory_manager=MemoryManager(stores=[store]))
await store.add("The user prefers dark mode", metadata={"kind": "pref"})
hits = await store.search("what theme does the user like?")
How it works
- Semantic recall via pgvector:
ORDER BY embedding <=> query(cosine distance) over an HNSW index — native ANN in Postgres. - You bring the embeddings. Default embedder is Amazon Bedrock Titan Text v2 (1024-dim, cosine); pass any
embeddercallable for OpenAI / Cohere / local models. - Each
addstores a row{id, content, embedding vector, metadata jsonb, created_at};searchembeds the query and runs the ANN search, surfacing the distance as_score. - The table, the
vectorextension, and the HNSW index are created automatically.
Requirements
The pgvector extension must be installed on the server. On Debian/Ubuntu: apt install postgresql-16-pgvector; on macOS (Homebrew): brew install pgvector; managed services (RDS, Cloud SQL, Azure) expose it as an extension. The store runs CREATE EXTENSION IF NOT EXISTS vector on init.
Configuration
PostgresMemoryStore(name, url=None, *, table_name="strands_memory", engine=None, description=None, max_search_results=None, writable=True, extraction=None, embedder=None, dimensions=1024, region_name=None)
The memory store (
strands-postgres-store) is distinct from the byte storage backend (strands-postgres-storage). Also published asstrands-store-postgres.
License
MIT
Metadata
Release files for strands-postgres-store 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| strands_postgres_store-0.1.0.tar.gz | 5.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| strands_postgres_store-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.5 kB
Release files / strands_postgres_store-0.1.0.tar.gz
| Download URL | strands_postgres_store-0.1.0.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fba36188c1a9945aa87c7b8ea555f59c101f96195d0c027294a10bb5743e8cce
|
|
BLAKE2b-256 checksum How to use checksums |
994f0af9de73b4721d53a655a4d901aa643e7f0bc9b2735f935bc7e10aee280e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Release files / strands_postgres_store-0.1.0-py3-none-any.whl
| Download URL | strands_postgres_store-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
10c5c3a60f2aab2446d6b9ef249d2645c4fa8e4122db4109c506ef32c664284f
|
|
BLAKE2b-256 checksum How to use checksums |
d789a661bde77e76a24e05b89a0689b2bee5369c2e93846107d8148a8b0a2589
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Security for strands-postgres-store 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.