SCM Memory: Embedded Lifecycle Memory for Agents
SCM gives Python and LangChain agents persistent lifecycle memory without an SCM server, hosted account, or SCM URL. It remembers facts and events, resolves corrections, consolidates during sleep, forgets stale noise, discovers schemas, and reports what changed when it wakes.
Install
pip install scm-memory
No SCM server, hosted account, base URL, or provider key is required.
Embedded Python
from scm import SCM
memory = SCM(user_id="alice")
memory.add_memory("Alice prefers concise answers.")
result = memory.search_memory("communication preference")
print(result["memories"])
memory.sleep("deep")
print(memory.wake_summary()["narrative"])
memory.close()
State is stored atomically under ~/.scm by default. No provider key is
required; SCM uses offline extraction and hash embeddings when no model is
configured.
LangChain 1.x
pip install "scm-memory[langchain]"
from langchain.agents import create_agent
from scm import SCM
memory = SCM(user_id="alice")
agent = create_agent(
model=model,
tools=[...],
middleware=[memory.langchain()],
)
agent.invoke({"messages": [{"role": "user", "content": "I prefer short answers."}]})
The middleware automatically:
- Recalls relevant memory before the first model call.
- Persists human messages with retry-safe message identity.
- Injects bounded memory and wake context as delimited untrusted data.
- Registers exactly
add_memory,search_memory,sleep,wake_summary, andforget. - Reuses the attached agent model for extraction when supported, while retaining an offline fallback.
The one-call helper is equivalent:
from scm.langchain import create_scm_agent
agent = create_scm_agent(model=model, tools=[...], user_id="alice")
Multi-User Applications
Application code supplies identity; the model never chooses it.
from scm import SCM, SCMContext
from scm.langchain import create_scm_agent
memory = SCM(namespace="support-app")
agent = create_scm_agent(model=model, tools=[...], memory=memory)
agent.invoke(
{"messages": [{"role": "user", "content": "Remember my timezone is IST."}]},
context=SCMContext(user_id="alice", thread_id="ticket-184"),
)
Set SCM_DATABASE_URL in the deployment environment to use PostgreSQL. Agent
code remains unchanged and contains no SCM endpoint.
Five Lifecycle Operations
| Operation | Purpose |
|---|---|
add_memory |
Persist a fact, event, preference, or observation. |
search_memory |
Recall relevant memory and update access state. |
sleep |
Consolidate, discover schemas, resolve interference, and forget. |
wake_summary |
Report what changed during sleep or idle time. |
forget |
Suppress one memory while preserving audit lineage. |
consolidate remains a backward-compatible alias for sleep.
Persistence and Administration
Local storage uses atomic replacement, checksums, process locking, restrictive
permissions, and last-known-good recovery. Optional encryption is enabled with
SCM_ENCRYPTION_KEY. PostgreSQL adds revisioned transactions, per-user locks,
and database-backed sleep leases for multi-worker deployments.
backup = memory.export_user()
memory.import_user(backup)
memory.delete_user() # hard deletion
Advanced Surfaces
REST, MCP, and the HTTP client remain supported for remote or non-Python deployments. The JavaScript package is a remote REST client; SCM 1.1 does not claim an embedded JavaScript runtime. See Integrations and Deployment.
Product Verification
python scripts/run_product_qualification.py
The release gate builds and installs the wheel outside the repository, runs plain Python and LangChain without an SCM server, checks lifecycle recovery, exercises the optional REST and JavaScript surfaces, and audits dependencies. It also runs deterministic lineage stress and credential-free multi-agent attribution gates. See Quality Gates and Safety Validation.
Documentation
- Getting Started
- LangChain Guide
- Product Thesis
- Architecture
- Deployment
- Safety Validation
- Research Artifacts
Research
The research paper motivates and evaluates SCM's lifecycle architecture. The product remains honest about the evidence: SCM targets interference, contradiction, schema discovery, curiosity gaps, and idle-time transformation; it is not a claim of universal superiority over retrieval systems.
- Published SCM paper (DOI: 10.5281/zenodo.21323877)
- Repository copy
- Reproducibility
- Versioned artifacts
License
Metadata
Release files for scm-memory 1.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 | |
|---|---|---|---|---|
| scm_memory-1.1.0.tar.gz | 438.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| scm_memory-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 803.7 kB
Release files / scm_memory-1.1.0.tar.gz
| Download URL | scm_memory-1.1.0.tar.gz |
|---|---|
| Size | 438.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7a6a135da1caaafa64b449a0f300b3f4b6af7aa0415f6955b2af65756dcb2dc3
|
|
BLAKE2b-256 checksum How to use checksums |
85e27b6bdbf2fe08ca7c780a9f38718e0cccb96c16212a31c8bbfca769a0c25b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / scm_memory-1.1.0-py3-none-any.whl
| Download URL | scm_memory-1.1.0-py3-none-any.whl |
|---|---|
| Size | 365.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c4d8d5d14a10c161be1d5ac6d21f0a406df7c43354ddd54560b2d2192520b7a5
|
|
BLAKE2b-256 checksum How to use checksums |
9b66fdc9ae3ad7743414d5046a35579d8caad4e38c81ee8ee6a9d643fa04c157
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for scm-memory 1.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.