strands-stash-plugin
Strands Stash is a stateful
workspace for agents. It mounts your context sources as one directory of
files: Amazon Bedrock AgentCore Memory, knowledge bases, web search, AWS
Context, MCP servers, and any store that a plugin serves. Your agent reads
that directory with tools it already knows, such as ls, cat, grep, and
jq. Source files stay outside the context window until the agent reads
them. Stash sends steering, digests, and compact result views through the
integration.
A source is one store that a mount shows as a folder of files. A plugin is a
program that serves a store as a source. Its list, get, and search
methods give records, and Stash makes a file of each one. plan says what the mount loads
when it starts. ingest writes the turns of the agent back.
This SDK speaks the plugin protocol for you: you write one Python function for each method that your store serves.
It needs Python 3.9 or later, and nothing else.
A plugin
This plugin searches the web:
import hashlib
import json
import socket
import urllib.error
import urllib.request
from datetime import datetime, timezone
from stash_plugin import Failure, Plugin, Record
plugin = Plugin("perplexity", description="The web, through the Perplexity Search API.")
@plugin.initialize
def start(settings, env):
key = env.get("PERPLEXITY_API_KEY", "").strip()
if not key:
raise Failure.validation("set env.PERPLEXITY_API_KEY")
return key
@plugin.search
def search(key, query, limit):
body = json.dumps({"query": query, "max_results": min(limit, 20)}).encode()
request = urllib.request.Request(
"https://api.perplexity.ai/search", data=body,
headers={"Authorization": f"Bearer {key}", "Content-Type": "application/json"})
try:
with urllib.request.urlopen(request, timeout=20) as answer:
results = json.load(answer)["results"]
except urllib.error.HTTPError as error:
if error.code in (408, 425):
raise Failure.timeout("Perplexity did not finish the search") from None
if error.code == 429:
raise Failure.throttled("Perplexity throttled the search") from None
if error.code >= 500:
raise Failure.unavailable("Perplexity is unavailable") from None
if error.code in (401, 403):
raise Failure.access_denied("Perplexity refused the API key") from None
raise Failure.other(f"Perplexity answered HTTP {error.code}") from None
except urllib.error.URLError as error:
if isinstance(error.reason, socket.timeout):
raise Failure.timeout("Perplexity did not answer") from None
raise Failure.unavailable("Perplexity is unavailable") from None
except socket.timeout:
raise Failure.timeout("Perplexity did not answer") from None
found = datetime.now(timezone.utc)
return [to_record(result, found) for result in results if result.get("url")]
def to_record(result, found):
url, snippet = result["url"], result.get("snippet") or ""
record_id = hashlib.sha256(f"{url}\0{snippet}".encode()).hexdigest()[:32]
return Record(
# The same passage of the same page keeps its file in each search.
id=record_id,
name=f"{record_id}.md",
body=f"{snippet}\n\nSource: {url}\n",
preview=snippet[:1000],
created_at=found,
)
main = plugin.run
initializegets thesettingstable of the source and the environment of the plugin. It returns thestatethat each other function gets first.listandsearchget a folder and filters only if the function has the parametersscopeandfilters. Otherwise the SDK refuses such a request withunsupported.- With no
@plugin.plan, the mount loads nothing until a search or get request. listreturns a page and the cursor of the next page (Noneat the end), or the records alone for the last page.searchreturns records, or(record, score)pairs, best first.ingestcan get the same batch again, with the sametoken: write it once. Return an id of the write, orNoneto use the token.- Raise a
Failure(not_found,access_denied,throttled,unavailable,timeout,validation,malformed, orunsupported). Any other exception isother, and its traceback goes to the daemon log, asprintdoes. - After
initialize, functions run on up to 8 threads at the same time. Keep the state thread-safe, for example asqlite3connection behind athreading.Lock. - Do not sleep for a rate limit. Raise
Failure.throttled, and Stash retries.
A Record
| Field | Description |
|---|---|
id |
The same for the same record in each call. |
body |
The text of the file. |
dir |
The folder below the source, such as team/runbooks. The SDK removes a / at the start or the end. |
name |
The whole file name, such as deploy.md or menu.csv. With none, the file is <date of created_at>__<words of the body>.md. |
preview |
The line that a search shows. With none, the body. |
created_at, updated_at |
A datetime (a naive one is UTC) or RFC 3339 text. |
The file is <dir>/<name>. A .md file is the body, then the time of the
fetch in a YAML block. Any other file is the body alone.
Follow the protocol's
path rules
when a store supplies dir or name.
Publish it
Name the package and its program stash-source-<plugin>. For a source with
no command, Stash runs that program from the PATH of the daemon.
[project]
name = "stash-source-perplexity"
dependencies = ["strands-stash-plugin"]
[project.scripts]
stash-source-perplexity = "stash_source_perplexity:main"
A user installs it with pipx install stash-source-perplexity, and adds a
source with no command:
[sources.web]
kind = "plugin"
plugin = "perplexity"
env = { PERPLEXITY_API_KEY = { command = ["op", "read", "op://me/perplexity/api-key"] } }
Stash sends ingest only when the source sets write.trajectory = {}. The
plugin gets only env and a few variables of the daemon, such as PATH and
HOME.
Try it
examples/notes.py
serves the Markdown files of one folder with @plugin.list, @plugin.get,
and @plugin.ingest. It needs no other package:
[sources.notes]
kind = "plugin"
plugin = "notes"
command = ["python3", "/path/to/examples/notes.py"]
settings = { root = "~/notes" }
env = { PYTHONPATH = "/path/to/integrations/plugin-sdk/python/src" }
Run the tests with python3 -m unittest discover -s tests.
Metadata
Release files for strands-stash-plugin 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| strands_stash_plugin-0.1.1.tar.gz | 21.9 kB | With provenance | Details for strands_stash_plugin-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| strands_stash_plugin-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for strands_stash_plugin-0.1.1-py3-none-any.whl |
Total release size: 35.4 kB
Release files / strands_stash_plugin-0.1.1.tar.gz
| Download URL | strands_stash_plugin-0.1.1.tar.gz |
|---|---|
| Size | 21.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1eb035840e8bae019129d2d8338316fe88ee19517bfb8eac2590fc4c83dc5554
|
|
BLAKE2b-256 checksum How to use checksums |
da0fa6135380ae6b82a79be374aba0e29e758c665f9288becb00834ec01067dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / strands_stash_plugin-0.1.1-py3-none-any.whl
| Download URL | strands_stash_plugin-0.1.1-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a73bf69a2a1bec771e76aa5169315bb5b43e9cc44aa9fd2f6f9bd66de13cb462
|
|
BLAKE2b-256 checksum How to use checksums |
d49060eb80fad19989cebbfe176879585e7a9718aadf7c46e92844cfec2b6b61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logSecurity for strands-stash-plugin 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for strands_stash_plugin-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.