Skip to main content

AWS Strands Agents session persistence backed by PerSQL — durable sessions, agents, and messages in an isolated SQLite database per agent.

Project description

strands-persql

AWS Strands Agents session persistence backed by PerSQL — durable sessions, agents, and messages in an isolated SQLite database per agent, provisioned instantly.

pip install strands-persql

Usage

import os
from strands import Agent
from persql import PerSQL
from strands_persql import PerSQLSessionManager

client = PerSQL(token=os.environ["PERSQL_TOKEN"])
manager = PerSQLSessionManager("user-42", client.database("acme/agent-state"))

agent = Agent(session_manager=manager)
agent("hi")  # history and state persist across restarts

Or let the manager own the client:

manager = PerSQLSessionManager.from_token("user-42", os.environ["PERSQL_TOKEN"], "acme/agent-state")

PerSQLSessionRepository is also exported for use with RepositorySessionManager or your own manager.

What it stores

The same data model as FileSessionManager, with tables instead of directories — one row per session (strands_sessions), per agent (strands_agents), and per message (strands_messages), each holding the dataclass's JSON. Multi-agent (Graph/Swarm) state goes to strands_multi_agents. Pass table_prefix= to change the strands_ prefix.

Limits

  • The repository contract is synchronous, so calls block on HTTP to your PerSQL database (or run in-process in local mode).
  • update_agent / update_message are read-then-write (to preserve created_at), not atomic over HTTP. Keep one writer per session — the same assumption Strands' file and S3 managers make.
  • Requires strands-agents >= 1.42, < 2 — the package subclasses SessionRepository, so a framework major version can change the contract.

Local mode for tests

from persql import PerSQL
manager = PerSQLSessionManager("t", PerSQL(local=":memory:").database("test/db"))

Runs against in-process SQLite — no network, no token.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strands_persql-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_persql-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: strands_persql-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for strands_persql-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3d798dbe2b6dfaefd873445bb6c400a7bfd6f9432ad777a15fec58446f32bd0a
MD5 345e3e6260446b959ef209c364c2b1d8
BLAKE2b-256 6f52727d5074a6252129d9ed505bfd72f5f49e9949f981759e3d67049eaa4c4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for strands_persql-0.1.0.tar.gz:

Publisher: python-release-strands.yml on persql/persql

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: strands_persql-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for strands_persql-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 07e2a0e6286280466ae97924b75695d67579498c6aa45ffca1e3364da41c52f7
MD5 297e9c4261661bf7a512116959fb6ec3
BLAKE2b-256 3716237ee43b4905392627688d1c00a60704c586e85f83f00af4627bd640bf5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for strands_persql-0.1.0-py3-none-any.whl:

Publisher: python-release-strands.yml on persql/persql

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page