Skip to content

Strands Agents Session

Pluggable session storage for Strands Agents — persist an agent's sessions, agent state, and messages so conversations resume across runs. A backend-agnostic core plus swappable storage providers.

The family

Package Backend Install
strands-agents-session core (interface + in-memory) pip install strands-agents-session
strands-session-dynamodb Amazon DynamoDB pip install "strands-agents-session[dynamodb]"
strands-session-mongodb MongoDB pip install "strands-agents-session[mongodb]"
strands-session-sql SQL via SQLAlchemy (Postgres, SQLite, MySQL) pip install "strands-agents-session[sql]"

Each provider is an independent PyPI package that pulls the core transitively — a DynamoDB user never installs Mongo code. Pick one directly, or via the core's extras.

Beyond sessions: storage & memory

The same family also provides two other Strands layers:

  • Storage backendsstrands.storage.Storage (durable bytes for snapshots, context offload, memory backing): strands-sql/postgres/mongodb-storage, strands-storage-dynamodb.
  • Memory storesMemoryStores with semantic recall via native vector search: strands-dynamodb-store (DynamoDB), strands-postgres-store (pgvector), strands-mongodb-store (Atlas).

Quick taste

from strands import Agent
from strands_session_dynamodb import DynamoDBSessionManager

agent = Agent(session_manager=DynamoDBSessionManager(
    session_id="user-123", table_name="strands-sessions",
))

agent("Hi, I'm Kamal")
agent("What's my name?")   # remembers within the session

Next run with the same session_id → the agent restores its full history and state.

Why this exists

Strands ships FileSessionManager and S3SessionManager. This family adds more backends — DynamoDB (cheaper/faster than S3 for small frequent session items), MongoDB, and any SQL database — behind one consistent interface, and makes writing your own backend a ~30-line job.

Design in one line

The core implements Strands' full SessionRepository over a tiny SessionStorage interface; a provider just implements that interface for its database. See Overview and Build Your Own Backend.

Storage only, by design

Message pruning in Strands is a ConversationManager concern, deliberately decoupled from storage. These packages never prune — doing so at the storage layer would corrupt Strands' message-index/offset restore logic.

Where to start