Durable, hybrid (structural + semantic) memory for AI agents and humans. Local-first, zero external services. Guided `cos setup` wizard + Sim-OS. v0.9: import ChatGPT/Claude history, export rules to CLAUDE.md/AGENTS.md/Cursor, RaaS usage metering, monetization-map builder.
Project description
ContinuityOS
๐ก๏ธ ContinuityOS โ AI Agent Governance Gateway
No dangerous tool runs unless ContinuityOS approves it. A local-first, MCP-native hard-boundary that AI coding agents (Claude Code, Cursor, Codex CLI) must pass through: every risky shell/file/git action gets a preflight decision โ
ALLOW ยท WARN ยท HOLD ยท DENY ยท REQUIRE_CONFIRMATION ยท DRY_RUN_ONLYโ with reasons, an append-only tamper-evident audit ledger, and a rollback plan. Apache-2.0.continuity run shell -- rm -rf / # โ BLOCKED โ command was NOT executed continuity run shell -- npm test # โ ALLOW โ runsContinuityBench v0: 100% decision accuracy, 9/9 dangerous actions stopped (vs 0/9 with no gateway). What makes it smarter than a static policy engine: it decides with continuity context (your canon/rules/state), not just regex. See BUILD_GATE_STATUS.md.
The memory + continuity layers below are the context engine that powers those decisions.
Durable memory + continuity layer for AI agents and humans. Local-first, zero external services, Apache-2.0.
Not just a vector store โ ContinuityOS keeps the thread between sessions and between versions of you and the model: memory (hybrid recall) + continuity (canon, frontiers, loops, checkpoints, anti-drift doctor, handoff) + a multi-agent council (many agents + you on one memory, authority levels & roles) + a digital twin (a behavioral model built from your own memory โ the humanโAI co-evolution / dyad layer) + an operator control plane (correct, redact, rollback, export).
Your Claude / ChatGPT / agent forgets everything between sessions. ContinuityOS is a small local memory layer that stores what matters โ who you are, your projects, your rules, decisions you've made โ and gives it back when it's relevant. It recalls both structurally (folder-like namespaces + keyword search) and semantically (vector similarity), so the right memory surfaces whether you match the words or just the meaning.
Nothing leaves your machine. One SQLite file. No cloud, no account, no telemetry.
Why
- Agents forget. Every new session starts cold. ContinuityOS persists context across sessions and tools.
- Hybrid recall. Keyword-only memory misses paraphrases; pure-vector memory misses exact facts and structure. ContinuityOS blends both.
- Structure like folders. Memories live in namespaces โ
identity,projects,rules,facts,events,notes(or your own) โ so recall can be scoped and a human can browse it. - For agents and humans. Use it from your code, from the CLI, from an MCP-capable client (Claude Desktop / Claude Code), or over a tiny HTTP API.
- Local-first & private. Core is stdlib-only โ no required dependencies, no services. Drop-in to anything.
Install
pip install continuityos # core (stdlib-only)
# optional, for production-grade embeddings:
pip install "continuityos[fast]" # recommended: FastEmbed / ONNX
pip install "continuityos[st]" # sentence-transformers
pip install "continuityos[m2v]" # light static model2vec
pip install "continuityos[embeddings]" # all optional embedders
Requires Python 3.10+.
Quick start
From the CLI
cos remember "Robert prefers Apache-2.0 licenses" -n rules -t license
cos remember "ContinuityOS = hybrid memory: FTS + vectors" -n projects
cos recall "which license should I pick?"
# 0.54 [rules] Robert prefers Apache-2.0 licenses (semantic 0.22 + keyword)
cos namespaces
Import your ChatGPT / Claude history
Bring your existing AI history into ContinuityOS โ bi-temporally, so
cos recall --as-of <date> reconstructs what you knew then instead of a flat dump:
cos import ~/Downloads/chatgpt-export/conversations.json # ChatGPT data export
cos import ~/Downloads/claude-export/ # Claude export dir (conversations.json + memories.json)
cos import export.json --extract # distill typed facts (decision/preference/...), not raw turns
cos import export.json --dry-run # preview counts, write nothing
Auto-detects both export formats; deterministic and offline (no API keys). Every
imported memory's valid_from is set to the original message time.
From Python
from continuityos import Memory
m = Memory("memory.db")
m.remember("The grid lab K=0.04 cohort led at +$1405 / 3 days", namespace="facts", tags=["trading"])
for hit in m.recall("best grid setup", k=3):
print(hit.score, hit.namespace, hit.text)
# inject straight into an agent prompt:
print(m.context("what do I know about grid trading?"))
As an MCP server (Claude Desktop / Claude Code)
ContinuityOS ships an MCP stdio server so an agent can remember and recall on its own. Add to your MCP client config:
{
"mcpServers": {
"continuityos": {
"command": "cos",
"args": ["--db", "~/.continuityos/memory.db", "serve"]
}
}
}
Tools exposed: remember, recall, context, forget, list_namespaces, checkpoint, handoff, doctor, set_frontier, predict, alignment, preflight_action โ 12 tools.
Now the agent pulls relevant memory automatically before answering โ and writes new facts back as it learns it.
Recommended: use the cross-platform bridge instead of cos serve:
{
"mcpServers": {
"continuityos": {
"command": "python",
"args": ["/path/to/mcp_bridge.py"]
}
}
}
See docs/MCP_INTEGRATION.md for Hermes, Claude Desktop, and Cursor setup.
Over HTTP (optional)
cos api --port 8077 # local-only: 127.0.0.1
curl -s "localhost:8077/recall?q=license&k=3"
curl -s -XPOST localhost:8077/remember -d '{"text":"hello","namespace":"notes"}'
Remote bind is intentionally opt-in:
export CONTINUITYOS_ALLOW_REMOTE=1 # required for --host 0.0.0.0
export CONTINUITYOS_TOKEN='change-me' # optional bearer auth for HTTP API
cos api --host 0.0.0.0 --port 8077
curl -H "Authorization: Bearer $CONTINUITYOS_TOKEN" "localhost:8077/health"
Real semantic recall (recommended)
The default embedder is offline & dependency-free. For real semantic quality (synonyms, paraphrases), switch in one line:
from continuityos import Memory
from continuityos.embedders import FastEmbedEmbedder # pip install "continuityos[fast]"
m = Memory("memory.db", embedder=FastEmbedEmbedder()) # bge-small, ONNX, no torch
Benchmark (see BENCHMARKS.md): recall@5 0.50 โ 1.00, MRR 0.38 โ 0.58. Real LoCoMo harness ready in bench/locomo_bench.py.
With Docker
docker compose up -d # HTTP API on :8077, memory persisted in ./cos-data
More than memory โ the continuity layer
A chat is a terminal, not memory. ContinuityOS persists the operating state that keeps work coherent across sessions:
- Canon โ slow, non-negotiable truths (who you are, rules you don't break).
- Frontiers โ
1 trunk + 1 cash + 1 labfocus discipline; classify every idea. - Open loops โ what's still unfinished, bounded so it can't sprawl.
- Checkpoints โ every session ends with
delta + next irreversible action + proof. - Doctor โ an anti-drift check: is a cash frontier set? loops bounded? checkpoint fresh? proof attached?
- Handoff pack โ one block (canon + frontiers + loops + last checkpoint) to resume in a new session or hand to another agent.
cos frontier trunk continuityos
cos frontier cash inner-circle
cos loop "ship v0.2 to GitHub"
cos checkpoint --summary "built continuity layer" --next "update sites" --proof continuity.py
cos doctor # โ
healthy 5/5 (or flags drift)
cos handoff # paste this into the next session
from continuityos import Continuity
c = Continuity(db="memory.db")
c.add_canon("Proof beats explanation. Closure beats branching.")
c.set_frontier("cash", "inner-circle")
c.checkpoint(summary="...", next_action="...", proof="path/to/artifact")
print(c.doctor()) # anti-drift report
print(c.handoff()) # resume-context block
Over MCP the agent gets checkpoint, handoff, doctor, set_frontier tools too โ so it maintains its own continuity, not just its recall.
How it works
remember(text, namespace, tags)
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Store โ one local SQLite file
โ items + FTS5 + vectors โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฒ
recall(query) โ HYBRID rank
โโโโโโโโโโโโโดโโโโโโโโโโโโ
structural / keyword semantic / vector
(FTS5 + namespace) (cosine over embeddings)
โโโโโโโโโโโโโฌโโโโโโโโโโโโ
blended score โ top-k
-
Structural layer โ
namespace(folder-like) +tags+ FTS5 full-text index. -
Semantic layer โ each memory is embedded to an L2-normalized vector; recall ranks by cosine similarity.
-
Hybrid score โ
semantic_weight ยท semantic + (1 โ semantic_weight) ยท keyword(tunable; default 0.6). -
Embeddings are pluggable โ the default
HashingEmbedderis deterministic and fully offline (great for privacy and tests). For best semantic quality, pass anystr โ list[float]callable (e.g. asentence-transformersmodel):from sentence_transformers import SentenceTransformer enc = SentenceTransformer("all-MiniLM-L6-v2") m = Memory("memory.db", embedder=lambda t: enc.encode(t, normalize_embeddings=True).tolist())
Privacy
ContinuityOS never sends your data anywhere. Memory is a single SQLite file on your disk. .gitignore is pre-configured to keep *.db, data/, and takeout/ out of version control by construction.
Standards & competitive position
The 2026 consensus is that guardrails belong at the gateway, not embedded in application code โ a control point that intercepts every tool invocation, scores its risk, and approves or blocks before execution. ContinuityOS is exactly that control point, and maps onto the frameworks enterprises are now audited against:
- OWASP LLM Top 10 โ preflight classifies and gates the agentic risks directly: prompt-injection-driven destructive commands, tool poisoning (D3 schema/forbidden-pattern checks), excessive agency (SAP capability passports), and missing audit (append-only ledger).
- NIST AI RMF / EU AI Act (high-risk obligations, in force Aug 2026) โ the tamper-evident decision ledger + rollback plan provide the record-level traceability and human-oversight hooks these frameworks require. Every decision is logged with reasons, severity, and a restore command.
- MCP-native โ runs as an MCP server; the same preflight governs MCP tool calls, the layer competitors (Cisco AI Defense, Lasso) now target.
What no one else has. The crowded 2026 field (Galileo Agent Control, Maxim Bifrost, Palo Alto Prisma AIRS, Lasso, Defend AI) enforces generic policy โ regex, ML classifiers, org rules. ContinuityOS decides with your continuity context: the same engine that remembers your canon and non-negotiable rules uses them to judge each action (_canon_check). That makes it the only gateway whose verdicts are personalized to the operator, not just the org. Plus two things detection-only tools skip: an instant local rollback module (snapshot โ continuity rollback <id>) and sovereign-local execution (zero data leaves the disk โ no SaaS egress, which is itself the top enterprise blocker: only 14.4% of agents reached production with full security sign-off in 2026).
Honest scope: rollback covers local files only; it cannot undo irreversible external side effects (network, prod, third-party APIs). The gateway raises the floor โ it is not a guarantee.
Two-tier memory & cost-aware routing
The strongest 2026 agents don't win on a bigger context window โ they win on how they handle the finiteness of context. ContinuityOS implements the two-tier pattern Anthropic and OpenAI both converge on:
- Session memory โ the auto-compactible state of the current run (goal, live hypotheses, found IDs, tool outcomes, unresolved blockers). Carried forward instead of re-derived each turn.
- Long-term memory โ durable lessons, stable user preferences, recurring patterns, anti-patterns, domain facts. One lesson per file; update the existing note, don't spawn duplicates โ the same discipline this repo's memory files follow.
context(query, k, max_tokens=โฆ, compact=โฆ) packs the most relevant long-term memories until a token budget is hit, so recall stays cheap, and its output order is deterministic โ which matters for prompt-cache stability.
Cache-friendly memory rules (preserve the prompt-cache hash; cache miss = paying full price every turn):
- Never put volatile values (
datetime.now(), random IDs, per-turn counters) in the system prompt or any cached prefix โ they reset the cache every call. Put them in the body of the last user message. - Keep tool definitions and the memory block in a stable, sorted order so the cached prefix is byte-identical across turns (
compact=True+ deterministic packing does this). - The cache threshold on Opus-4.8 is ~1024 tokens โ keep the cached prefix above it to actually benefit.
- To change instructions mid-run without busting the cache, inject a
role:"system"message into the history rather than editing the cached system prompt.
Cost-aware routing. estimate_cost(text, model_id, output_tokens) prices a context block against a built-in MODEL_REGISTRY (Fable 5, Mythos 5, Opus 4.8, Haiku 4.5, GPT-5.5, Gemini 3.1 Pro / 3.5 Flash, Grok 4.3, DeepSeek V4 Pro โ mid-2026 pricing). Same block costs ~28ร more on Fable 5 than DeepSeek V4 Pro, so callers can route commodity โ interactive โ high-stakes tiers instead of always paying frontier price for trivial work.
Why continuity, not just memory
Models are the consumable. Continuity is the asset. Every model upgrade (or vendor switch) normally resets your agent โ it forgets your rules, your context, your decision history. ContinuityOS stores the agent outside the model: one SQLite file (canon + rules + bi-temporal facts + decision checkpoints + a behavioral twin). Swap the model underneath and cos boot brings back the same agent. Model-agnostic by design โ vendor memory locks you to their model; this doesn't.
Sim-OS โ closed-loop simulation on top of the memory core
Beyond memory, ContinuityOS ships an experimentation layer: continuityos/sim/ is a durable OODA loop that lets an agent propose hypotheses, run them in an isolated simulation engine (Pandora), and crystallize only verified results into canon โ with a risk-scoring governance gate, a hallucination-loop detector, and autonomous rollback. The point is epistemic safety: the agent can experiment and fail freely, but canon never gets poisoned.
cos sim --objective edge --iters 6 # run the closed loop (mock engine)
See continuityos/sim/README.md for the architecture.
Composable โ built on in the wild
ContinuityOS is a memory + governance engine, not a closed product โ the point is what other developers layer on top. Two independent integrations appeared in its first days:
- Sim-OS โ Pandora (in this repo,
continuityos/sim/) โ a closed-loop simulation bridge: the memory/governance core drives an external simulation engine (Pandora) and crystallizes only verified results into canon. - A cognitive-memory layer built independently on ContinuityOS as its engine โ semantic keys, a write-time policy gate, and explainable ranking on top of the core store. That integration fed straight back upstream: the key-based
find(namespace, key)andupsert()primitives added in v0.9 came from it โ a real dependency, not a fork.
That second loop is the design working as intended: keep the core a small, generic, stdlib-only engine, and let domain-specific layers compose on top and send missing primitives back. The Memory API, the governance gate, and sim/ are the extension seams.
Honest limits (threat model)
We'd rather tell you the edges than oversell. Full detail in THREAT_MODEL.md.
- The gateway is not magic. It stops known-dangerous shell/file/git commands (rm -rf, force-push, secret reads, curl|sh). It does not understand arbitrary application logic โ a subtle bug inside a script it's allowed to run is out of scope.
execmode is argv-only and refuses shell operators;shellmode runs them but is classified more strictly. - Rollback is local-only. It reverts local file/DB state. It cannot undo irreversible external side effects (a bad API call to prod, a deleted GitHub repo, a sent transaction). Gate those actions upstream; don't rely on rollback.
- Default embedder is weak on purpose. The zero-dependency
HashingEmbedderis fast but semantically shallow. For real synonym/paraphrase recall installcontinuityos[fast](ONNX, ~bge-small) or[m2v](30MB static). We publish honest LoCoMo retrieval numbers inBENCHMARKS.mdโ not answer-graded marketing figures. - Memory can go stale. A fact true last week can be wrong today. Use bi-temporal
supersede()/recall(current_only=True)so corrections hide stale facts instead of contradicting them. Don't hand an agent raw memory without the current-only filter for state-sensitive decisions. - It asks for discipline. Continuity relies on session-close rituals (
cos checkpoint) and periodiccos doctor. Skip them and the store drifts toward a log dump. This is a feature (auditable thread), but it is real operator work. - Prompt-cache hygiene. If you inject memory into a system prompt, keep it deterministic โ a dynamic value (e.g.
datetime.now()) busts the cache and you pay full context cost every call.context(..., compact=True)returns cache-stable output; don't wrap it in per-call timestamps.
Best fit today: operators and teams that need auditable, governed continuity (regulated internal ops, on-call/shift handoff, coding agents with rollback). Overkill if you just want Git-style backups and paste context by hand.
Status
v0.8.2 โ 6 layers, 12 MCP tools, 37/37 tests, full audit passed. Unified core, all tested (FastEmbed-accelerated recall, session rituals boot/close/compress, recall benchmark in bench/): L1 Memory (hybrid FTS+vector, WAL + thread-safe store) ยท L2 Continuity (canon/frontiers/loops/checkpoints/doctor/handoff) ยท *
Project details
Release history Release notifications | RSS feed
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 continuityos-0.9.0.tar.gz.
File metadata
- Download URL: continuityos-0.9.0.tar.gz
- Upload date:
- Size: 126.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cdb05f95e8ae711b889dc29a0759d09aaedee467c67ba5e7179c2c67d697736f
|
|
| MD5 |
d5c9816bf7fa7545a567a2006eee93f6
|
|
| BLAKE2b-256 |
507193ee6b19be27c69f52372da19743d61aae73a7038b84b43b4f9a1476fb95
|
Provenance
The following attestation bundles were made for continuityos-0.9.0.tar.gz:
Publisher:
publish.yml on bitmaster162/continuityos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
continuityos-0.9.0.tar.gz -
Subject digest:
cdb05f95e8ae711b889dc29a0759d09aaedee467c67ba5e7179c2c67d697736f - Sigstore transparency entry: 2073216575
- Sigstore integration time:
-
Permalink:
bitmaster162/continuityos@f6c22a5777c4fc929f7cdfa3a7986cb168a6d306 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/bitmaster162
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f6c22a5777c4fc929f7cdfa3a7986cb168a6d306 -
Trigger Event:
push
-
Statement type:
File details
Details for the file continuityos-0.9.0-py3-none-any.whl.
File metadata
- Download URL: continuityos-0.9.0-py3-none-any.whl
- Upload date:
- Size: 120.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01b9b40a5d7692208b8b282caaf0ae79d2feb90ab2c549ae2aec99b56f076248
|
|
| MD5 |
7bd93e2fde11c70b8bcc09e793748f5d
|
|
| BLAKE2b-256 |
4f61c303c40a472a1b879f4bcc1420c0a9fe22ca3b6b7b551a373d6ab644bac4
|
Provenance
The following attestation bundles were made for continuityos-0.9.0-py3-none-any.whl:
Publisher:
publish.yml on bitmaster162/continuityos
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
continuityos-0.9.0-py3-none-any.whl -
Subject digest:
01b9b40a5d7692208b8b282caaf0ae79d2feb90ab2c549ae2aec99b56f076248 - Sigstore transparency entry: 2073216587
- Sigstore integration time:
-
Permalink:
bitmaster162/continuityos@f6c22a5777c4fc929f7cdfa3a7986cb168a6d306 -
Branch / Tag:
refs/tags/v0.9.0 - Owner: https://github.com/bitmaster162
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f6c22a5777c4fc929f7cdfa3a7986cb168a6d306 -
Trigger Event:
push
-
Statement type: