AI memory engine with identity preservation โ remember everything, forget nothing
Project description
๐ Cortex by evaOS
Drop-in persistent memory engine for AI agents.
Your agent wakes up tomorrow and still knows who it is.
What is Cortex?
Cortex is a drop-in persistent memory engine for AI agents. It solves the three failure modes of naive AI memory: identity drift, junk accumulation, and no lifecycle.
Key differentiators:
- ๐ชจ Cornerstones โ always-on identity memories that inject at the start of every session, bypassing semantic retrieval. Your agent's core identity is guaranteed to be present.
- ๐ Dream Cycles โ async memory consolidation via a persistent CircadianEngine. Memories are scored, promoted, decayed, and synthesized while your agent sleeps.
- ๐ฅ Multi-tenant โ full
owner_idisolation. One Cortex instance serves multiple users with complete memory separation. - ๐ Provider-agnostic โ pluggable LLM and embedding providers: Venice, Mistral, Google, Voyage. Switch without re-embedding.
Production-ready out of the box:
- ๐ One-command Fly.io deploy via
cortex-fly.toml - ๐พ Litestream continuous backup + GitHub Actions daily snapshot
- ๐ก Sentry error tracking + performance spans
What's New in v1.4.0
v1.4.0 is the memory scoping + entity intelligence release.
- ๐ญ Entity-scoped retrieval โ filter memories by
entity_idandentity_typeon retrieve, search, and browse endpoints. Your agent can now recall memories about specific people, projects, or concepts (#923, #931) - โณ Temporal claims โ memories have
valid_from/valid_tolifecycle. Expired claims are excluded by default; include withinclude_expired=true. NewGET /memories/timelineendpoint for subject history (#925, #931) - ๐ฅ Entity visibility lifecycle โ entities progress through
extracted โ promoted โ activestates based onconnection_count. Dashboard-ready entity intelligence (#933, #938) - ๐ญ Peer promotion โ peers promoted to canonical actor identities with
peer_type,status,permissions_json, andconnection_count. First-class support for multi-actor systems (#932, #941) - ๐งน Extraction quality โ predicate filter removes junk claims (code artifacts, bot names, ephemeral actions) + prompt tuning for better extraction (#929, #940)
- ๐ Cortex-proxy โ Supabase edge function for CORS-free dashboard access with path traversal protection (#928, #937)
Previous highlights (v1.3.x):
- ๐ฆ Hippo LCM โ Lossless Context Management: compaction, summarization, retrieval (#869โ#871)
- ๐ชจ Cornerstone always-on injection โ identity cornerstones inject unconditionally every session (#733)
- ๐ Static API key auth โ
X-Cortex-API-Keyheader replaces JWT complexity (#737) - ๐ Dream engine persistent scheduler โ CircadianEngine starts at server boot (#776)
See the full CHANGELOG for all fixes and changes.
Architecture
Cortex processes memory through a five-layer pipeline:
Capture โ Extract โ Reconcile โ Retrieve โ Dream
| Layer | What It Does |
|---|---|
| Capture | Intercepts conversation turns and session events |
| Extract | LLM-powered claim extraction with noise filtering |
| Reconcile | Smart conflict resolution: ADD / UPDATE / SUPERSEDE / NOOP |
| Retrieve | Hybrid BM25 + vector search with Reciprocal Rank Fusion |
| Dream | Async consolidation, decay, synthesis, and contradiction resolution |
Cornerstone Layer
Cornerstones are identity memories that inject first, every session. They bypass semantic retrieval entirely โ they are always present, always loaded, and protected from accidental deletion. This is the foundation of identity preservation.
Session Start
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Cornerstone Load โ โ unconditional, always first
โ (identity anchors) โ
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Semantic Retrieval โ โ query-dependent context
โ (BM25 + vector) โ
โโโโโโโโโโโโฌโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโ
โ Context Injection โ
โ (system prompt) โ
โโโโโโโโโโโโโโโโโโโโโโโ
Provider System
Cortex uses a pluggable provider system for both LLM and embedding operations:
| Capability | Default Provider | Alternatives |
|---|---|---|
| LLM extraction | Venice (mistral-small-3-2-24b-instruct) |
Google, OpenAI, Anthropic |
| Embeddings | Venice BGE-M3 (1024-dim) | Voyage, Google, OpenAI |
| Reranking | Voyage | โ |
Switch providers at runtime via config or env vars โ no re-embedding required.
Full Pipeline
โโโโโโโโโโโโโโโโโโโโโ SESSION LIFECYCLE โโโโโโโโโโโโโโโโโโโโโ
โ โ
โ WAKE MID-TURN SLEEP โ
โ โโโโ โโโโโโโโ โโโโโ โ
โ โ
โ โโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Wake โ โ Retrieve โ โ Sleep Pipeline โ โ
โ โ Pipelineโ โ Pipeline โ โ S1 Consolidation โ โ
โ โ W1โW4 โ โ BM25+Vector โ โ S2 Promotion โ โ
โ โโโโโโฌโโโโโ โ +RRF+Rerank โ โ S3 Handoff โ โ
โ โ โโโโโโโโโฌโโโโโโโ โ S4 Carry-Forward โ โ
โ โผ โ โโโโโโโโโโโโโโโโโโโโโโ โ
โ โโโโโโโโโโโ โ โฒ โ
โ โ Boot โ โผ โ โ
โ โ Loader โ โโโโโโโโโโโโโโโโโ โโโโโโโดโโโโโโโ โ
โ โ(cornerstonesโ โTask-Mode โ โ Circadian โ โ
โ โ identityโ โClassifier โ โ Engine โ โ
โ โ prefs) โ โโโโโโโโโฌโโโโโโโโ โ (dream, โ โ
โ โโโโโโฌโโโโโ โ โ deep dreamโ โ
โ โ โผ โ decay) โ โ
โ โ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โ
โ โ โRetrieval โ โ
โ โ โPolicy Engine โ โ
โ โ โโโโโโโโโฌโโโโโโโโ โ
โ โ โ โ
โ โ โผ โ
โ โ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโ โ
โ โ โ Context โ โ Re-Retrieval โ โ
โ โ โ Compiler โโโโ (topic shift, โ โ
โ โ โ (bundle + โ โ new entities) โ โ
โ โ โ compress) โ โโโโโโโโโโโโโโโโโ โ
โ โ โโโโโโโโโฌโโโโโโโโ โ
โ โ โ โ
โ โ โผ โ
โ โ โโโโโโโโโโโโโโโโโ โ
โ โโโโโโโโบโ Injection โ โ
โ โ Slot Manager โ โ
โ โโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Install
pip install evaos
With vector search (recommended):
pip install "evaos[vec]"
All extras (LLM providers, HTTP API, MCP server):
pip install "evaos[all]"
Quick Start
Environment Variables
# Required
export CORTEX_API_KEY=your-secret-key
# Provider (Venice โ default)
export VENICE_API_KEY=your-venice-key
export CORTEX_EMBEDDING_MODEL=text-embedding-bge-m3
export CORTEX_PROVIDER_LLM_MODEL=mistral-small-3-2-24b-instruct
# Optional: Voyage reranking
export VOYAGE_API_KEY=your-voyage-key
CLI
# Initialize a new memory store
evaos init
# Teach it something
evaos remember "Andrew is the founder of 100Yen Org. He lives in Bangkok."
# Ask it later
evaos recall "Where does Andrew live?"
# โ Andrew lives in Bangkok. He is the founder of 100Yen Org.
# Check config
evaos config show
# Validate provider config
evaos config validate
Python SDK
import asyncio
from evaos import Cortex
async def main():
cortex = Cortex(db_path="my_memory.db")
await cortex.initialize()
# Start a session โ cornerstones inject automatically
await cortex.wake(session_id="session_001")
# Store information โ claim extraction happens automatically
await cortex.remember("Andrew is the founder of 100Yen Org. He lives in Bangkok.")
# Retrieve relevant memories for an LLM prompt
context = await cortex.retrieve("Where does Andrew live?")
print(context.context_block)
# โ "Andrew lives in Bangkok. He is the founder of 100Yen Org."
# End the session โ dream cycle consolidates
await cortex.sleep(session_id="session_001")
asyncio.run(main())
HTTP API
# Start the server
evaos serve --port 8420
# Store a memory
curl -X POST http://localhost:8420/api/v1/remember \
-H "X-Cortex-API-Key: your-secret-key" \
-H "Content-Type: application/json" \
-d '{"content": "Andrew founded 100Yen Org in Bangkok."}'
# Retrieve memories
curl http://localhost:8420/api/v1/retrieve?query=Andrew \
-H "X-Cortex-API-Key: your-secret-key"
Deploy to Fly.io
# Clone and deploy
git clone https://github.com/100yenadmin/electric-sheep.git
cd electric-sheep
fly launch --config cortex-fly.toml
fly secrets set CORTEX_API_KEY=your-secret-key VENICE_API_KEY=your-venice-key
fly deploy
Docker
git clone https://github.com/100yenadmin/electric-sheep.git
cd electric-sheep
export CORTEX_API_KEY=your-secret-key
export VENICE_API_KEY=your-venice-key
docker compose up -d
# HTTP API at http://localhost:8420
Features
๐ง Memory Pipeline
| Layer | What It Does |
|---|---|
| Extraction | LLM-powered claim extraction with noise filtering (skips "changed line 47 of auth.py") |
| Entity Resolution | Fuzzy deduplication โ "Andrew", "andrew", "@andrew" โ same person |
| Reconciliation | Smart conflict resolution: ADD / UPDATE / SUPERSEDE / NOOP |
| Cornerstones | Always-on identity anchors โ inject first, every session, no keywords needed |
| Token Budget | Assembles memory context within configurable token ceilings |
๐ Dream Cycles
A persistent CircadianEngine starts at server boot and runs async memory consolidation:
- Standard Dream โ Ebbinghaus decay, contradiction resolution, cross-session synthesis
- Deep Dream โ Generative memory synthesis; Gen1 Soul restoration (new in v1.3.0)
- Extraction Failure Queue โ Failed extractions retried automatically in dream cycles
๐ Auth & Multi-Tenancy
- Static API key โ
X-Cortex-API-Keyheader. Simple, secure, no JWT complexity. - Multi-tenant โ
owner_idresolved per-request from API key. Complete memory isolation between users. - Soft-delete โ Deleted memories retained for 90 days, restorable via API. Dream cycle purges after expiry.
๐ Commitments & Open Loops
First-class tracking of agent commitments and unresolved threads. Both inject into session boot context for continuity across sessions.
๐ฌ Dialectic Engine
Ask your memory natural-language questions. Fast path for simple lookups, agentic multi-step QueryPlanner for complex reasoning across your memory graph.
๐ Hybrid Retrieval
BM25 full-text search + vector similarity with Reciprocal Rank Fusion. Optional Voyage reranking for high-stakes queries.
๐ก Observability
- Sentry โ error tracking + performance spans in wake pipeline and retrieval
- Health endpoint โ version, dream cycle timestamp, system status
- Metrics โ pipeline counters, histograms, gauges, quality gates
๐ Five Interfaces
| Interface | Use Case |
|---|---|
| CLI | evaos remember, evaos recall, evaos ask, evaos dream, evaos config |
| HTTP API | FastAPI REST server โ evaos serve |
| MCP Server | Model Context Protocol for agent frameworks โ evaos mcp |
| TypeScript SDK | @evaos/client โ typed client for Node.js applications |
| OpenClaw Plugin | cortex โ drop-in memory plugin for OpenClaw agents |
OpenClaw Plugin
Cortex ships an OpenClaw plugin (cortex) that bridges your agent's memory to a running Cortex instance.
// openclaw.plugin.json (included in openclaw-plugin/)
{
"id": "cortex",
"kind": "memory"
// configSchema: cortexUrl, apiKey, ownerId, autoRecall, autoCapture, ...
}
What it does:
- before_agent_start โ loads cornerstones unconditionally, then retrieves semantic context
- agent_end โ captures conversation as new memories (fire-and-forget)
- session_start / session_end โ calls wake/sleep for session lifecycle
Tools exposed: cortex_search, cortex_remember, cortex_forget, cortex_update_commitment, cortex_resolve_open_loop
See openclaw-plugin/ for full source and configuration schema.
Configuration
# cortex.toml
[cortex]
storage_backend = "sqlite"
[cortex.storage]
db_path = "cortex.db"
[cortex.extraction]
model = "mistral-small-3-2-24b-instruct"
coding_noise_filter = true
[cortex.embedding]
model = "text-embedding-bge-m3"
provider = "venice"
[cortex.cornerstones]
max_count = 7
drift_threshold = 0.05
[cortex.circadian]
dream_cycle_enabled = true
dream_cycle_hour_utc = 8
deep_dream_enabled = true
[cortex.deprecation]
forgetting_curve = "ebbinghaus"
soft_delete_retention_days = 90
See docs/product/guides/configuration.md for the full reference.
Documentation
| Document | Path |
|---|---|
| Getting Started | docs/product/guides/getting-started.md |
| HTTP API Reference | docs/product/api/http-reference.md |
| Configuration Guide | docs/product/guides/configuration.md |
| Fly.io Deployment | docs/product/ops/fly-deployment-guide.md |
| Architecture Overview | docs/product/architecture/overview.md |
| Changelog | CHANGELOG.md |
Python SDK Reference
from evaos import Cortex
# Default โ Venice provider, stores in cortex.db
cortex = Cortex()
# Customised
cortex = Cortex(
db_path="~/my_app/memory.db",
profile="companion",
llm_provider="venice",
extract_model="mistral-small-3-2-24b-instruct",
embed_model="text-embedding-bge-m3",
)
Core Methods
| Method | Description |
|---|---|
await cortex.initialize() |
Initialize storage + apply migrations |
await cortex.wake(session_id) |
Start session, load cornerstones unconditionally |
await cortex.remember(content) |
Store text; extraction is automatic |
await cortex.retrieve(query) |
Hybrid BM25 + vector search, returns context block |
await cortex.ask(query) |
Dialectic engine โ ask your memory questions |
await cortex.sleep(session_id) |
End session, trigger consolidation |
await cortex.dream() |
Run dream cycle manually |
await cortex.seal_cornerstone(label, content) |
Pin an identity anchor |
await cortex.check_drift() |
Drift scores for all cornerstones |
await cortex.health() |
System health dict |
await cortex.stats() |
Memory counts (claims, entities, cornerstones, sessions) |
await cortex.export(format="json") |
Export all active memories |
TypeScript SDK
npm install @evaos/client
import { CortexClient } from '@evaos/client';
const client = new CortexClient({
baseUrl: 'http://localhost:8420',
apiKey: 'your-api-key',
});
await client.remember('Andrew is the founder of 100Yen Org.');
const results = await client.recall('Who is Andrew?');
See sdks/typescript/ for full documentation.
CLI Reference
evaos init [--profile companion|coding|enterprise]
evaos remember "text"
evaos recall "query"
evaos ask "question"
evaos ask "question" --agentic
evaos cornerstones list
evaos cornerstones seal --label "name" --content "text"
evaos dream
evaos config show
evaos config set-provider
evaos config validate
evaos config export
evaos config apply-fly
evaos stats
evaos health
evaos export [--format json|sql]
evaos serve [--port 8000]
evaos mcp
evaos backup [--output path]
Project Structure
cortex/ # Python modules (~52K lines)
โโโ core/ # Extraction, entity resolution, reconciliation, retrieval,
โ # working memory, token budget, task-mode, boot loader
โโโ storage/ # SQLite adapter with FTS5 + vector support, v3-v16 migrations
โโโ brain_graph/ # Document memory graph with file watching
โโโ circadian/ # Dream engine: CircadianEngine, Deep Dream, CuriosityEngine
โโโ sleep/ # Staged sleep pipeline: S1โS2โS3โS4
โโโ capture/ # Wake pipeline: W1-W4 activation routing
โโโ commitments/ # Commitment/open loop tracking
โโโ deprecation/ # Ebbinghaus decay + soft-delete pipeline
โโโ identity/ # Cornerstone guardian + drift calculator
โโโ config/ # TOML config + `evaos config` CLI
โโโ api/ # FastAPI HTTP server (85+ endpoints)
โโโ integrations/ # MCP server + plugin interface
โโโ dialectic/ # Dialectic engine (ask your memory)
โโโ peers/ # Peer modeling (relationship tracking)
โโโ events/ # Event emitter + webhook dispatcher
โโโ llm/ # Multi-provider LLM abstraction (Venice, Google, OpenAI)
โโโ cli.py # Click-based CLI
โโโ sdk.py # High-level Cortex class
โโโ types.py # Shared dataclasses and types
dashboard/ # 8-page web UI (SPA)
sdks/typescript/ # @evaos/client TypeScript SDK
openclaw-plugin/ # cortex OpenClaw plugin (TypeScript)
deploy/ # cortex-fly.toml, Litestream config, startup scripts
Benchmarks
# Full suite
python -m benchmarks.run_benchmarks
# Skip slow 10K retrieval
python -m benchmarks.run_benchmarks --skip-retrieval
Results saved to benchmarks/results/latest.json. Nightly CI runs LoCoMo eval at 02:00 UTC.
Contributing
See CONTRIBUTING.md for dev setup, testing, and PR guidelines.
License
MIT โ 100Yen Org
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 evaos-1.6.1.tar.gz.
File metadata
- Download URL: evaos-1.6.1.tar.gz
- Upload date:
- Size: 1.6 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
074a7ff87541411f953eda6412e04505b96c41ea1db275056e2186e7add3bf21
|
|
| MD5 |
ffdec8c714169e0edaf573eff1b2da02
|
|
| BLAKE2b-256 |
db858b37fb43f0edd07d4e74fd37bf87090a93b88a8c1ff15ced57e75a1520e4
|
Provenance
The following attestation bundles were made for evaos-1.6.1.tar.gz:
Publisher:
publish.yml on 100yenadmin/electric-sheep
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
evaos-1.6.1.tar.gz -
Subject digest:
074a7ff87541411f953eda6412e04505b96c41ea1db275056e2186e7add3bf21 - Sigstore transparency entry: 1189539843
- Sigstore integration time:
-
Permalink:
100yenadmin/electric-sheep@46f0cb18bf0fa18c72f1a90615269c579f2c6912 -
Branch / Tag:
refs/tags/v1.6.3 - Owner: https://github.com/100yenadmin
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@46f0cb18bf0fa18c72f1a90615269c579f2c6912 -
Trigger Event:
release
-
Statement type:
File details
Details for the file evaos-1.6.1-py3-none-any.whl.
File metadata
- Download URL: evaos-1.6.1-py3-none-any.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b991f16a928b25052cac5fb327735694607a2d2b831a6e9105faf82eb6c6738
|
|
| MD5 |
b2030fc85f670746f566056a6578afab
|
|
| BLAKE2b-256 |
b0eb64ef6c68c6bf1ab7e941761ab55280cd779bc82496d4bf4522c7dcc7e702
|
Provenance
The following attestation bundles were made for evaos-1.6.1-py3-none-any.whl:
Publisher:
publish.yml on 100yenadmin/electric-sheep
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
evaos-1.6.1-py3-none-any.whl -
Subject digest:
9b991f16a928b25052cac5fb327735694607a2d2b831a6e9105faf82eb6c6738 - Sigstore transparency entry: 1189539848
- Sigstore integration time:
-
Permalink:
100yenadmin/electric-sheep@46f0cb18bf0fa18c72f1a90615269c579f2c6912 -
Branch / Tag:
refs/tags/v1.6.3 - Owner: https://github.com/100yenadmin
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@46f0cb18bf0fa18c72f1a90615269c579f2c6912 -
Trigger Event:
release
-
Statement type: