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 SnapshotSessionManager
from strands_github_storage import GithubStorage

storage = GithubStorage(owner="myorg", repo="agent-sessions", token="ghp_...")
agent = Agent(session_manager=SnapshotSessionManager("agent-sessions", 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.1.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.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: strands_github_storage-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 cd013b039e5d913fd5134322d4ee60151ed0f73ff0f0ea6311f7007ab84a13cd
MD5 50c3640e460328b2c7b67ebb1b2ec8bf
BLAKE2b-256 f3eec15f1ebb56d1f5ec0189596e0636cd9d9481a4886a6547112cb737a01ea9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for strands_github_storage-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1fae6518a1e9bd06d9cc3eb7fff82c764b75c999a933a18ccebd868c6de2327b
MD5 3686da9f1693a734ef5bbf40780349ad
BLAKE2b-256 8b4b30b273f1cdce4e128eea90c753fb20f83eb89b8354fca4c40fc9a0d96572

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