Safer Agent Memory Standard (SAMS)
Security-first memory for AI agents. Scoped memory tiers, taint tracking, tenant isolation and human-reviewed consolidation, as a short standard, a zero-dependency Python reference implementation, a conformance test suite and a Claude Code plugin that applies it to your project.
Your agent's memory is a persistence mechanism for prompt injection. One poisoned web page, scan result or email, written to memory, is read by every future session. SAMS is a set of rules and tests that stops that from happening.
Why
Most agent memory projects focus on recall: how to store and find the right memory. SAMS focuses on governance:
- Scopes.
org,project,tenant,run. Agents write freely only to their own run scratchpad. - Taint. Sessions that read outsider-controlled content are marked by the harness, not the agent. Their writes never reach curated memory unreviewed.
- Tenant isolation. One customer's data never reaches another's memory, or shared memory.
- Dreaming. A scheduled job reviews many sessions and proposes changes (redacted, flagged, with evidence). A human accepts or rejects each one.
- Guardrails. Versioning with provenance, optimistic locking, permissions enforced below the agent.
It builds on the context-engineering practices Anthropic has described publicly (memory as files, progressive disclosure, out-of-band consolidation) and adds the security controls needed when agents handle untrusted input and multiple tenants. SAMS is vendor-neutral and works with any model or agent framework.
What's in the repo
| Path | What it is |
|---|---|
STANDARD.md |
The standard (MUST/SHOULD rules, ~10 minute read) |
sams/ |
Python reference implementation: harness, SQLite backend, redaction, CLI. Stdlib only |
conformance/ |
Backend-agnostic tests C1-C11. Plug in your backend, run pytest |
skills/adopt-memory/ |
Claude Code skill: inspects your repo and applies the standard |
templates/ |
Project profile, Claude Code setup, Docker Compose isolation, dreaming job and prompt |
Quick start
Let your coding agent apply it
Install as a Claude Code plugin (or copy skills/adopt-memory and STANDARD.md into your repo), then in your project:
/adopt-memory
The skill inspects the project, writes docs/memory-profile.md, asks you the decisions it must not make alone (tenant unit, taint sources, retention), then builds the right tier and proves it with the conformance tests.
Not using Claude Code? Give STANDARD.md to any coding agent and ask it to follow section 0.
Use the library
pip install safer-agent-memory # import sams; CLI: sams
from sams import SQLiteBackend, AgentSession, DreamerSession, Owner
backend = SQLiteBackend("memory", read_only=["org"])
session = AgentSession(backend, session_id="s-001", agent="recon-agent", assigned="tenant:acme")
# Taint sources are wrapped by the harness; calling them marks the session.
fetch = session.tainting(my_http_fetch, reason="web_fetch")
# Give the model only these four tools.
tools, schemas = session.tools(), session.tool_schemas()
# Session start: memory as labelled data, not instructions.
context = session.context_block()
Agent writes to run:s-001 land immediately. Writes to tenant:acme are queued as pending (redacted, flagged and versioned, so what you accept is exactly what you reviewed). Writes to org or another tenant are refused.
python templates/dreaming/dream.py --base memory --scope tenant:acme --transcripts logs/acme
sams review list --base memory --scope tenant:acme
sams review show --base memory --scope tenant:acme 3
sams review accept --base memory --scope tenant:acme 3
sams pending list --base memory --scope tenant:acme
sams pending show --base memory --scope tenant:acme waf.md s-001
sams history --base memory --scope tenant:acme methodology/waf.md
Claude Code sessions only
For a repo where the only "agent" is your coding assistant, copy templates/claude-code/ into the repo: lean CLAUDE.md, deny rules on curated files, a notes/ scratchpad, and dream.sh, a weekly job that proposes memory changes on a dream/<date> branch for you to review like a PR.
Conformance
pip install -e ".[test]"
pytest
| ID | Requirement |
|---|---|
| C1 | Agent writes to run succeed; writes to org are refused |
| C2 | Agent writes above run land as pending |
| C3 | Taint is recorded and cannot be cleared by the agent |
| C4 | Agents cannot set author, status or taint |
| C5 | Concurrent writes: one wins, one conflicts, nothing is lost |
| C6 | Full history with provenance; one-step restore |
| C7 | Tenant A cannot read or write tenant B |
| C8 | The dreaming role can propose but not write |
| C9 | Planted secrets never reach a stored proposal, diff or pending write |
| C10 | Instruction-like and sensitive proposals are flagged |
| C11 | Pending entries are never served as curated memory; memory text cannot escape its context wrapper |
| C12 | The owner promotes exactly what they reviewed; later changes cause a conflict |
To test another backend, implement sams.backend.Backend and add a factory to conformance/conftest.py.
Storage forms
| Form | Use when |
|---|---|
| File-backed markdown in git | One repo or one agent, including coding-assistant memory |
File-backed + derived SQLite index (sams index) |
Large repos where grep over memory gets noisy |
SQLite, one directory per scope (SQLiteBackend) |
All agents on one host; isolation via Docker mounts |
| Postgres with row-level security | Agents across hosts or serverless (reference backend planned for v0.2) |
Roadmap
- v0.2: Postgres/Supabase backend with RLS policies; MCP server exposing the four tools; Postgres in the conformance matrix.
- v0.3: TypeScript port of the harness; adapters for common agent frameworks.
Status
Draft (v0.1). The rules are stable enough to use; names and APIs may change before 1.0. Redaction and flagging are pattern-based safety nets, not guarantees; the human review gate is the control. Feedback and conformance reports from real deployments are the most useful contributions.
License
Code: Apache-2.0. Standard text (STANDARD.md, templates and docs): CC BY 4.0.
Maintained by Final Frontier Ventures.
Metadata
Release files for safer-agent-memory 0.1.0
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 | |
|---|---|---|---|---|
| safer_agent_memory-0.1.0.tar.gz | 32.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| safer_agent_memory-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 66.9 kB
Release files / safer_agent_memory-0.1.0.tar.gz
| Download URL | safer_agent_memory-0.1.0.tar.gz |
|---|---|
| Size | 32.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67b006b5763f9b1af4a4eb97c5603573f897c5bffa89fd1ff80420acb922d012
|
|
BLAKE2b-256 checksum How to use checksums |
43a42f1dffe9c8d3e1c119cd4e4c668edd2ead511341381efaff4b7458a88d6e
|
| 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 Oct 27, 2026.
Transparency logRelease files / safer_agent_memory-0.1.0-py3-none-any.whl
| Download URL | safer_agent_memory-0.1.0-py3-none-any.whl |
|---|---|
| Size | 34.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
740064e9208a9cf350a359f064de0b1c6df226699c1dde0385368d1dfb26ad04
|
|
BLAKE2b-256 checksum How to use checksums |
873a6ea0f2ae8a38c8e1f3c347d641346199cbc33395a42fc0e111a77ec0d83b
|
| 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 Oct 27, 2026.
Transparency logSecurity for safer-agent-memory 0.1.0
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for safer_agent_memory-0.1.0.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 Oct 27, 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.