Local-first, IDE-agnostic agentic memory lifecycle manager
Project description
๐ง ContextOS
Stop paying for tokens your AI doesn't need.
A local-first proxy and memory layer for Claude Code, Cursor, Codex CLI, Continue, and Aider. ContextOS sits between your AI IDE and the cloud LLM (Anthropic, OpenAI) โ classifying every conversation turn by heat, trimming stale context, and cutting your Anthropic / OpenAI token bill 50โ70% on long coding sessions. Zero session data leaves your machine.
๐ contextosmem.netlify.app ยท ๐ฆ PyPI ยท ๐ Issues
pip install contextos-dd && contextos install
โจ What it does
Every long Claude Code, Cursor, or Codex session resends the entire conversation history to Anthropic or OpenAI on every turn โ that's where your token bill comes from. ContextOS is the local-first LLM context window manager that fixes this: it runs as a tiny FastAPI proxy on
127.0.0.1, classifies each turn HOT / WARM / COLD / DEAD by relevance, drops duplicates, and replaces stale runs with summaries โ all on your machine, with no telemetry and no cloud sync.
| ๐ชถ | 50โ70% fewer tokens on long sessions |
|---|---|
| โก | Sub-100ms overhead โ local FastAPI proxy with streaming passthrough |
| ๐ | Zero telemetry, zero cloud sync โ everything in ~/.contextos/ |
| ๐งฉ | Works with 5 IDEs out of the box โ one install command, all of them |
| ๐ | Live dashboard showing what was trimmed, what was saved, and why |
| ๐พ | Append-only ledger โ your history is never destroyed, just compressed for transit |
๐ 60-second install
pip install contextos-dd
contextos install
That single command:
- ๐ Detects supported IDE configs (Claude Code, Cursor, Codex CLI, Continue, Aider)
- ๐พ Backs them up to
~/.contextos/backups/ - ๐ Patches them to route through the local proxy on
127.0.0.1:9137 - ๐ฅ Downloads two small models (~430 MB, one time) to
~/.contextos/models/ - โถ๏ธ Starts the daemon and opens the dashboard in your browser
๐ก Offline / air-gapped? Use
contextos install --skip-models. Models download on first compaction.
๐ See INSTALL.md for the full walkthrough.
๐งฌ How it works
โโโโโโโโโโโโโโ raw history โโโโโโโโโโโโโโโโโโ trimmed payload โโโโโโโโโโโโโโโโ
โ Claude Codeโ โโโโโโโโโโโโโโโโโโบ โ ContextOS โ โโโโโโโโโโโโโโโโโโโโบ โ Anthropic โ
โ Cursor โ โ (localhost โ โ OpenAI โ
โ Codex โ โโโโโโโโโโโโโโโโโโ โ :9137) โ โโโโโโโโโโโโโโโโโโโโ โ โ
โโโโโโโโโโโโโโ streamed reply โโโโโโโโโโฌโโโโโโโโ full response โโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโดโโโโโโโโโโโ
โ Local DuckDB + โ
โ Qwen2.5-0.5B + โ
โ bge-small-en โ
โโโโโโโโโโโโโโโโโโโโโโ
Every turn in your conversation is tagged by heat:
| Heat | Meaning | What ContextOS does |
|---|---|---|
| ๐ฅ HOT | last 5 turns | Always sent verbatim |
| โ๏ธ WARM | within last 15 | Always sent verbatim |
| โ๏ธ COLD | older | Replaced by a narrative summary from local Qwen2.5 |
| ๐ DEAD | duplicate or empty | Dropped silently |
Trigger phrases like "as we discussed earlier" fire a vector recall from a local LanceDB store and re-inject the missing context on the next turn โ so summarized history is still semantically retrievable.
๐๏ธ Commands
| Command | What it does |
|---|---|
contextos install |
Detect IDEs, back up configs, patch URLs, download models, start daemon + dashboard |
contextos install --skip-models |
Same as above but skip the model download (air-gapped) |
contextos start |
Start daemon + dashboard; auto-snapshots the ledger first |
contextos start --no-dashboard |
Start the daemon only (no browser) |
contextos start --foreground |
Run daemon in the foreground (debugging) |
contextos stop |
Stop daemon and dashboard |
contextos status |
Show daemon health and detected IDEs |
contextos dashboard |
Launch the Streamlit dashboard at http://127.0.0.1:9138 |
contextos doctor |
Preflight checks: paths, deps, ports, IDE configs |
contextos export <sid> --out file.json |
Export full untrimmed history for a session (proves nothing was deleted) |
contextos warmup |
(Re-)download local models |
contextos uninstall |
Restore original IDE configs, stop daemon |
๐ฆ What gets downloaded
| File | Size | Purpose |
|---|---|---|
Qwen2.5-0.5B-Instruct-Q4_K_M.gguf |
~400 MB | Compaction โ summarizing COLD turns |
bge-small-en-v1.5 ONNX |
~30 MB | Embeddings for semantic recall |
One time. Lives on disk forever. Re-pull anytime with contextos warmup.
๐ Privacy
ContextOS is local-first by construction:
- ๐ซ No telemetry. Zero. We do not phone home.
- ๐ซ No cloud sync. Sessions, summaries, embeddings, logs โ all in
~/.contextos/on your machine. - ๐ซ No background uploads. Ever.
- โ Your code never reaches a third party. The only outbound call ContextOS makes is forwarding your IDE's request to the LLM you already chose.
The only network traffic ContextOS initiates on its own:
- Model downloads during
install/warmup(from HuggingFace) - Forwarding your IDE's chat requests upstream โ the same request your IDE was going to send anyway, just smaller.
๐ Where stuff lives
~/.contextos/ (Windows: %LOCALAPPDATA%\DataDojo\contextos\)
โโโ ledger.duckdb # append-only session + turn ledger
โโโ daemon.pid # daemon process id
โโโ dashboard.pid # dashboard process id
โโโ backups/ # snapshots: ledger backups + IDE config backups
โ โโโ ledger-20260517-091944.duckdb
โ โโโ settings.json.<ts>.bak
โโโ archive/ # LanceDB vector store of compacted turns
โโโ models/ # Qwen2.5 GGUF + bge-small ONNX
โโโ logs/
โโโ contextos.log # rolling app log (10MB ร 5)
โโโ daemon.stdout.log
โโโ daemon.stderr.log
contextos uninstall restores IDE configs and stops the daemon. It does not delete the ledger or models โ they stay in case you reinstall. Nuke everything by deleting the directory above.
๐ฉน Troubleshooting
The daemon won't start / "Daemon didn't become healthy in 30s"
contextos start --foreground
Runs the daemon in your terminal so you can see the real error live. Common culprits:
- Port 9137 already in use โ another tool grabbed it.
contextos doctorwill flag this. - AVX-512 crash on Intel 12th/13th-gen โ already pinned to
llama-cpp-python==0.2.90, but if you upgraded manually, downgrade back. - Long Paths not enabled (Windows) โ see INSTALL.md.
- Look at the logs:
~/.contextos/logs/daemon.stderr.logis the smoking gun.
Claude Code / IDE feels frozen or returns errors after install
Emergency kill-switch โ disables trimming without uninstalling:
# Windows
set CONTEXTOS_PASSTHROUGH=1
contextos stop && contextos start
# macOS / Linux
export CONTEXTOS_PASSTHROUGH=1
contextos stop && contextos start
This makes the proxy a transparent pipe โ your IDE works exactly like before, but you keep the dashboard and ledger. If this fixes the issue, please open a GitHub issue with the contents of ~/.contextos/logs/daemon.stderr.log.
Full rollback:
contextos uninstall # restores original IDE configs
Then restart your IDE.
Dashboard shows empty charts or "no data"
The dashboard needs a few turns of activity before charts populate:
- Most panels need 1+ active session โ use your IDE for a couple of minutes.
- Some charts (by-IDE / by-model breakdowns) only render meaningfully when you have multiple sessions across multiple tools.
- The "RUNNING" spinner at top-right is Streamlit's autorefresh โ that's normal.
Worried about losing chat history
You can't lose it. The ledger is append-only โ classification and rebuild only affect what gets sent upstream, never what's stored on disk.
Prove it to yourself:
contextos status # find your session id
contextos export <session_id> --out my_history.json
You'll get a JSON file with every turn ever recorded for that session, in order. Plus, contextos start snapshots the ledger to backups/ automatically every time it runs (keeps the last 7).
"Dashboard skipped: streamlit not installed"
pip install 'contextos-dd[dashboard]'
Uninstall didn't fully clean up
contextos uninstall is intentionally conservative โ it restores IDE configs and stops the daemon, but leaves your ledger and models. Wipe everything by deleting the data directory:
- Windows:
rmdir /s %LOCALAPPDATA%\DataDojo\contextos - macOS/Linux:
rm -rf ~/.contextos
๐ฃ๏ธ Roadmap
| Version | Status | Highlights |
|---|---|---|
| v0.1.0 | โ shipped | Initial MVP: proxy, ledger, classifier, compactor, dashboard |
| v0.1.1 | โ shipped | Windows daemon stability + LanceDB API drift fix |
| v0.1.2 | โ shipped | Dashboard reads daemon over HTTP (fixes DuckDB lock on Windows) |
| v0.1.3 | โ shipped | Protocol-aware pipeline (tool_use linkage, cache_control, fail-closed validator) + seamless one-command launch + auto-backup |
| v0.1.4 | ๐ง planned | Dashboard UX overhaul with narrative insights |
| v0.2.0 | ๐ญ planned | Per-conversation session IDs, OpenAI tool-calling pinning, local semantic search |
| Pro | ๐ญ future | MCP server, team/shared memory, React+WebSocket dashboard, cloud rollups (optional, encrypted) |
๐ ๏ธ Develop
git clone https://github.com/skappal7/context-os
cd context-os
pip install -e ".[dev,dashboard]"
ruff check .
pytest -q
55 tests across the proxy, classifier, compactor, ledger, dashboard, and safety layer. Includes a realistic Claude Code fixture (tool_use + tool_result + cache_control) that locks in the v0.1.3 regression fix.
๐ License & credits
Apache-2.0. Built by DataDojo.
Vendored under the hood: FastAPI ยท DuckDB ยท LanceDB ยท llama.cpp (via llama-cpp-python) ยท fastembed ยท Qwen2.5 ยท BAAI/bge-small-en ยท Streamlit.
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 contextos_dd-0.1.5.tar.gz.
File metadata
- Download URL: contextos_dd-0.1.5.tar.gz
- Upload date:
- Size: 59.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96e095d5808d246add6f4710d84b9346d7639af980c29ce90215e81808d824bc
|
|
| MD5 |
33cf4fe6a21d228e3089ab17fc907e5e
|
|
| BLAKE2b-256 |
24854c2bdfce3d1177ceb358faaded493171b11095768dbcbaccfe0388464b06
|
Provenance
The following attestation bundles were made for contextos_dd-0.1.5.tar.gz:
Publisher:
release.yml on skappal7/context-os
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
contextos_dd-0.1.5.tar.gz -
Subject digest:
96e095d5808d246add6f4710d84b9346d7639af980c29ce90215e81808d824bc - Sigstore transparency entry: 1615462724
- Sigstore integration time:
-
Permalink:
skappal7/context-os@c1375ae6dea7be59f01a354fbae3dd6ed12e8d60 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/skappal7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c1375ae6dea7be59f01a354fbae3dd6ed12e8d60 -
Trigger Event:
push
-
Statement type:
File details
Details for the file contextos_dd-0.1.5-py3-none-any.whl.
File metadata
- Download URL: contextos_dd-0.1.5-py3-none-any.whl
- Upload date:
- Size: 51.4 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 |
de6d67bb6bb97639c9c339e90fa198a30a35cb7cd3ea28383b8611e3f38a9c0a
|
|
| MD5 |
61559885b6723427ae555414a576d4e6
|
|
| BLAKE2b-256 |
ac56e6fc134335f330483bece441f87b11b4c85f80d80d9cd341eadf9e9b1d99
|
Provenance
The following attestation bundles were made for contextos_dd-0.1.5-py3-none-any.whl:
Publisher:
release.yml on skappal7/context-os
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
contextos_dd-0.1.5-py3-none-any.whl -
Subject digest:
de6d67bb6bb97639c9c339e90fa198a30a35cb7cd3ea28383b8611e3f38a9c0a - Sigstore transparency entry: 1615462726
- Sigstore integration time:
-
Permalink:
skappal7/context-os@c1375ae6dea7be59f01a354fbae3dd6ed12e8d60 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/skappal7
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@c1375ae6dea7be59f01a354fbae3dd6ed12e8d60 -
Trigger Event:
push
-
Statement type: