SCM: memory that works like yours — wake + sleep phases for AI agents.
Project description
SCM — Memory that works like yours
Other memory layers store facts. SCM learns from them while you're idle.
SCM (Sleep-Consolidated Memory) is the first agent memory layer with both a wake phase and a sleep phase — like the only memory system in nature that actually works.
📄 Paper (35 pages) · 🛠 Deployment guide · 🔌 Integrations · 🗺 Roadmap · 📊 Benchmarks
What's different
Every other agent memory product does the same thing in different shapes: store facts, retrieve facts. They never think between sessions. Your agent forgets to think the moment you stop talking to it.
That's not how memory works in any system that does it well — including yours. Sleep is when memory consolidates. When you sleep, your hippocampus replays the day's experiences and your cortex abstracts patterns from them. You wake up with a better version of yesterday's understanding, not the same one.
SCM does both phases:
| Phase | What happens | Bio analog | SCM modules |
|---|---|---|---|
| Wake | Selective attention. Encoding-by-importance. Cue-driven retrieval. Contradiction handling. Bounded working memory (~7 items). | Hippocampal encoding, working memory, cue-driven recall | Phases 1-5 |
| Sleep | Pattern abstraction. Contradiction resolution. Adaptive forgetting. Knowledge-gap detection and curiosity-driven filling. Wake summary report. | NREM consolidation, REM dreaming, synaptic homeostasis | Phase 7 (M1-M6) |
The result the user sees: when they come back from being away, the agent reports what it noticed.
> What did you notice while I was away?
While you were away I noticed three things:
• You've changed jobs — I've moved you from Northstar Robotics to Atlas Labs.
• Your Tuesday-morning runs and Friday-night dinners with Mara have become weekly patterns.
• You've mentioned 'OAuth flow' five times without explaining it; I read up on it.
(Authorization protocol, redirect-based, token + scope.)
This moment is the product. No other open-source memory system has it.
Five-line quickstart
from scm import SCMEngine
engine = SCMEngine(profile="chatbot")
engine.message("Hi, I'm Saish. I run every Tuesday morning.")
engine.message("Tuesday again — out for a 5K.")
engine.sleep("deep")
print(engine.wake_summary().narrative)
# → "While you were away I noticed Tuesday-morning running has become a pattern..."
Or, drop the SCM MCP server into Claude Desktop / Cursor / any MCP client and add five tools (add_memory, search_memory, consolidate, wake_summary, forget) automatically. See docs/INTEGRATIONS.md.
Install
pip install scm-memory
For local development from this repository:
git clone https://github.com/Saish15/sleepai.git
cd sleepai
python -m venv venv && source venv/bin/activate
pip install -e ".[dev]"
For the recommended privacy-first profile (free, local, no cloud calls):
ollama pull nomic-embed-text # 274 MB embedding model (recommended)
ollama pull llama3.2:latest # ~4 GB chat / extraction model
That's it. SCM auto-detects Ollama and uses it. Four deployment profiles documented in docs/DEPLOYMENT.md:
| Profile | LLM | Embedding | Cost / 30 turns | Privacy |
|---|---|---|---|---|
| A Offline-only | heuristic regex | sentence-transformers MiniLM | $0 | 100% local |
| B Ollama-only (recommended) | Ollama llama3 | Ollama nomic-embed-text | $0 | 100% local |
| C Hybrid | DeepSeek-chat | Ollama nomic-embed-text | ~$0.04 | text→cloud, vectors local |
| D All-cloud | OpenAI gpt-4o-mini | OpenAI text-embedding-3-large | ~$0.06 | all→cloud |
Works seamlessly with any LLM and any harness
SCM doesn't care which LLM you use. Concept extraction goes through LLMExtractor; switch providers with one env var:
LLM_PROVIDER=ollama # local, free
LLM_PROVIDER=deepseek # cheap cloud
LLM_PROVIDER=openai # premium
# Anthropic / Voyage / Together / any OpenAI-compatible endpoint also works
Same for embeddings — sentence-transformers, Ollama, or any OpenAI-compatible provider.
Drop SCM behind any agent framework:
- MCP server (Claude Desktop, Cursor, ChatGPT-with-MCP) —
scm mcpin your config - REST API (
/v1/memories,/v1/wake-summary, etc.) — OpenAPI 3.1 spec at/v1/openapi.json - Python SDK —
from scm import SCMEngine - JavaScript SDK —
import { SCM } from "scm-memory"(Node 18+, Bun, browsers, Edge runtime) - LangChain memory adapter — drop-in
BaseChatMemorysubclass - Plain HTTP — POST
/v1/memoriesfrom anything
Tool definitions exported in OpenAI / Anthropic / Gemini / OpenAPI formats from one source. See docs/INTEGRATIONS.md for 7 integration recipes.
What SCM is NOT
- ❌ Not a vector database. It uses one (NetworkX in-memory + SQLite/Postgres backing), but the value is the lifecycle, not the index.
- ❌ Not an LLM. Bring your own.
- ❌ Not a chat UI. It's the memory backend; the UI is your problem (or wire it to the included
/staticdemo page). - ❌ Not just a fact-extraction prompt over a vector DB. SCM is a complete memory pipeline — encoding, binding, retrieval, consolidation, forgetting, schema abstraction.
- ❌ Not 100% production-polished yet. v0.7.x is research-grade with strong tests; the deployment guide closes most rough edges. See
docs/STATUS.mdfor an honest current-state read.
Honest comparison
We don't claim to dominate every memory benchmark. We dominate a different axis.
| Capability | Stateless vector layer | SCM |
|---|---|---|
| Vector retrieval | ✅ | ✅ |
| Working-memory bound | ❌ | ✅ |
| Event-structured encoding | ❌ | ✅ |
| Spreading-activation retrieval | ❌ | ✅ |
| Contradiction-safe versioning | ❌ | ✅ |
| Sleep-stage consolidation | ❌ | ✅ |
| Schema extraction (REM) | ❌ | ✅ |
| Wake-summary endpoint | ❌ | ✅ |
| Curiosity-driven gap-filling | ❌ | ✅ |
| Idle-aware autonomous learning | ❌ | ✅ |
SCM does both jobs: vector retrieval (the table-stakes feature) plus continuous learning during idle time (the differentiator).
Status
- 322 regression tests passing (
pytest tests/ -q) - 143 focused regression tests for Phase 7 + retrieval (
pytest tests/test_*spreading* tests/test_*idle* tests/test_*curiosity* -q) - 16/16 brutal LangChain harness scenarios passing (multi-day persona, contradiction, idle wake-summary, multi-user isolation, failure mode)
- 5,561× p50 latency speedup on
add_memorysince v0.7.2 (async ingest) - 5-40× RAM saved at multi-user scale since v0.7.3 (embedding-model singleton)
See docs/BENCHMARKS.md for every measured number with reproduction instructions.
Architecture
┌───────────────────────────────┐
│ YOUR AGENT / HARNESS │
│ (LangChain, Claude, custom) │
└─────────────┬─────────────────┘
│
▼
┌───────────────────────────────────────────┐
│ SCM CORE │
│ Wake-phase: encode → bind → retrieve │
│ Sleep-phase: consolidate → schema → gap │
│ Phase 7: M1 idle daemon │
│ M2 cross-session pool │
│ M3 schema extraction (REM) │
│ M4 wake-summary endpoint │
│ M5 curiosity engine │
│ M6 lifecycle policy │
└────────┬─────────────────────┬─────────────┘
│ │
▼ ▼
┌───────────────────┐ ┌───────────────────┐
│ LLM BACKEND │ │ EMBEDDING │
│ Ollama/DeepSeek/ │ │ Ollama/OpenAI/ │
│ OpenAI/etc. │ │ sentence-trans. │
└───────────────────┘ └───────────────────┘
35-page paper at research/SCM_Final_Paper.pdf. Documents architecture, formal definitions for all 11 equations, brutal-testing methodology, ALB pilot, LoCoMo + LoCoMo++ honest comparisons, encoder-dependence analysis.
Project status
This project is in active development, working toward a public launch. See docs/STATUS.md for an unvarnished read of where it stands as a product, and docs/ROADMAP.md for what's coming next. The paper is ready and staged for arXiv submission but held until the product-readiness checklist completes — papers without products fade.
License
MIT. See LICENSE.
Contact
blobopera@proton.me
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scm_memory-0.7.7.tar.gz.
File metadata
- Download URL: scm_memory-0.7.7.tar.gz
- Upload date:
- Size: 272.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec853aa5f2bee034883a4f2ff6586a521f3946778d3b25a11fdbacdaa9612ad3
|
|
| MD5 |
bd836891b3d303f7ad94ff1b20b4f2de
|
|
| BLAKE2b-256 |
1637464a0de56f9803863551ccc40fd1099b4f74653a5a8565f6fac44ce72436
|
File details
Details for the file scm_memory-0.7.7-py3-none-any.whl.
File metadata
- Download URL: scm_memory-0.7.7-py3-none-any.whl
- Upload date:
- Size: 220.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b0c4ef980fb09a84e3b2f2b5ced667d0419aabe1bc8409711c00069ed0c86c0
|
|
| MD5 |
418cb1a27545a91f97ac1b4c64161a48
|
|
| BLAKE2b-256 |
cfdfcd0857400c00400274be1e4f70d6a65a1f574176aba98d41402e5968a969
|