Skip to main content

strands-github-storage (Python)

A GitHub-repository Storage backend for Strands Agents.

Persists each key as a file in a GitHub repository, at the key's path on a branch. Because the store is a git repo, its contents are browsable in the GitHub UI, diffable per change, and versioned in history. Implements the SDK's Storage interface, so it works anywhere a Storage is accepted — session snapshots and context offloading.

Install

pip install strands-github-storage

strands-agents and PyGithub are installed as dependencies.

Usage

import asyncio
from strands_github_storage import GithubStorage

storage = GithubStorage(
    owner="myorg",
    repo="agent-memory",
    branch="main",          # optional, defaults to "main"
    token="ghp_...",        # required for writes and private repos
)

async def main() -> None:
    await storage.write("facts/note.md", b"remember this")
    data = await storage.read("facts/note.md")   # bytes | None
    keys = await storage.list("facts/")          # ["facts/note.md"]
    await storage.delete("facts/note.md")

asyncio.run(main())

With a session manager

from strands import Agent
from strands.session import SessionManager
from strands_github_storage import GithubStorage

storage = GithubStorage(owner="myorg", repo="agent-sessions", token=token)
agent = Agent(session_manager=SessionManager(storage=storage))

Configuration

Parameter Required Description
owner yes Repository owner (user or organization login).
repo yes Repository name.
branch no Branch to read from and commit to. Defaults to main.
token for writes GitHub token. Needed for any write and for reading private repos.
github no A pre-configured PyGithub Github client, as an alternative to token.

Behavior and limits

  • One commit per operation. Each write and delete is its own commit (update <key> / delete <key>). A burst of writes produces a burst of commits.
  • Single writer per branch. Commits advance the branch ref without a compare-and-swap retry, so a concurrent writer that moves the branch head surfaces GitHub's non-fast-forward rejection as a StorageError rather than being retried.
  • read is limited to files under the GitHub contents API's inline-response ceiling (~1 MB). Markdown memory is far below this.
  • list fails loud on truncation. GitHub's git-tree API caps very large trees and does not paginate; rather than return a silent partial listing, list raises a StorageError.

Development

pip install -e ".[dev]"
pytest
ruff check src tests
mypy src

License

Apache-2.0

Download files

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

Source Distribution

strands_github_storage-0.1.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

strands_github_storage-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for strands_github_storage-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8f9e6efd16e4f317ca1f82993c992cb43595c192dad2645b8f404ccf3c5e79eb
MD5 7fb020742402d2b44119bb5e4cb0d8b8
BLAKE2b-256 b435a273487bf27b2c8b9bb740b48d6f7af8a007231439723a4091ce57b174d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strands_github_storage-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a704648f198b73d8653eedd5b7f60d23faa45fd31cb69e2cf3b6bb6661b3d55
MD5 f12d1e70e6eec921843b523e56c85c63
BLAKE2b-256 0a12d6a443fade879bd2ff2f51d1af2688cd56b345e1c0c3f63145200134b374

See more details on using hashes here.

Supported by

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