Skip to main content

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 embedder callable for OpenAI / Cohere / local models.
  • Each add stores a row {id, content, embedding vector, metadata jsonb, created_at}; search embeds the query and runs the ANN search, surfacing the distance as _score.
  • The table, the vector extension, 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 as strands-store-postgres.

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

strands_postgres_store-0.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strands_postgres_store-0.1.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file strands_postgres_store-0.1.0.tar.gz.

File metadata

  • Download URL: strands_postgres_store-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.5

File hashes

Hashes for strands_postgres_store-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fba36188c1a9945aa87c7b8ea555f59c101f96195d0c027294a10bb5743e8cce
MD5 facd0e42c01ed4c5e6ccc62833fe1b3e
BLAKE2b-256 994f0af9de73b4721d53a655a4d901aa643e7f0bc9b2735f935bc7e10aee280e

See more details on using hashes here.

File details

Details for the file strands_postgres_store-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for strands_postgres_store-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 10c5c3a60f2aab2446d6b9ef249d2645c4fa8e4122db4109c506ef32c664284f
MD5 2c0069a5e3e384d60a19f82c5a8794f7
BLAKE2b-256 d789a661bde77e76a24e05b89a0689b2bee5369c2e93846107d8148a8b0a2589

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page