Skip to main content

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.

Website PyPI Python License Tests Local-First

๐ŸŒ 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:

  1. ๐Ÿ” Detects supported IDE configs (Claude Code, Cursor, Codex CLI, Continue, Aider)
  2. ๐Ÿ’พ Backs them up to ~/.contextos/backups/
  3. ๐Ÿ”Œ Patches them to route through the local proxy on 127.0.0.1:9137
  4. ๐Ÿ“ฅ Downloads two small models (~430 MB, one time) to ~/.contextos/models/
  5. โ–ถ๏ธ 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 doctor will 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.log is 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.


๐ŸŒ contextosmem.netlify.app

If ContextOS saves you tokens, give it a โญ on GitHub.

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

contextos_dd-0.1.5.tar.gz (59.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

contextos_dd-0.1.5-py3-none-any.whl (51.4 kB view details)

Uploaded Python 3

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

Hashes for contextos_dd-0.1.5.tar.gz
Algorithm Hash digest
SHA256 96e095d5808d246add6f4710d84b9346d7639af980c29ce90215e81808d824bc
MD5 33cf4fe6a21d228e3089ab17fc907e5e
BLAKE2b-256 24854c2bdfce3d1177ceb358faaded493171b11095768dbcbaccfe0388464b06

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextos_dd-0.1.5.tar.gz:

Publisher: release.yml on skappal7/context-os

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for contextos_dd-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 de6d67bb6bb97639c9c339e90fa198a30a35cb7cd3ea28383b8611e3f38a9c0a
MD5 61559885b6723427ae555414a576d4e6
BLAKE2b-256 ac56e6fc134335f330483bece441f87b11b4c85f80d80d9cd341eadf9e9b1d99

See more details on using hashes here.

Provenance

The following attestation bundles were made for contextos_dd-0.1.5-py3-none-any.whl:

Publisher: release.yml on skappal7/context-os

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page