npm i -g billion-context MIT runs on your machine, sees nothing else

Month-long sessions
on a 100K window.

billion-context is a local context-compression proxy for AI coding agents — billion-context is all you need. Small context windows are enough: it keeps a 100K-window model working for days at a time, cuts token spend by up to 5×, and accounts for every token it moves.

  • Prompt-cache-aware compaction — rewrites cost almost nothing
  • A per-request ledger: new content vs. repay cost, visible in-terminal
  • Works as a transparent proxy — no agent source changes required

×5

fewer tokens per task

174,327

model calls in the longitudinal study

18.8B

cumulative input tokens compressed

0

window violations on 204,800-token models

Figures from the open-sourced study (4.5 months, 3 hosts, marathon sessions of 8,584–12,049 calls) — see the paper below.

Works with the agents you already run

Claude Code Codex OpenCode pi Gemini CLI Kimi Qwen Code GitHub Copilot CLI TRAE CodeBuddy Qoder iFlow CLI MiniMax Code deepseek-harness Amp aider goose hermes zcode omp jcode

How it works

Not a bigger window — a better layout. Four mechanisms keep months of work inside an ordinary context limit:

Folded, not rewritten

When history outgrows its budget, only the newly consumed slice is folded into a compact summary block — once per block, ever. The window oscillates in a bounded band instead of growing without limit; production sessions ran months at ten-thousand-plus calls. Any block decompresses back to full text when you need the detail.

The provider's cache stays warm

A fold deactivates old ranges without touching the front of the conversation, so the prompt-cache prefix survives turn after turn — 94.2% of active input was served from cache in the study. Rewrite-style compaction invalidates the whole prefix and re-bills it. This does not.

The model decides what to forget

A versioned compression doctrine lives in the system prompt; a growth-gated nudge says when folding pays off. The agent judges what the task still needs, may refuse, and compresses between steps — never mid-step.

Every token is accounted

Each request is sampled into a per-session ledger — new content, cache reads, compression repay, TTL expiry — plotted in percentage points on a trajectory chart. Audit real savings with /acp in the terminal or the built-in web UI at /__bili/.

Up and running in under a minute

One npm package, Node 22+. Then pick your connection style:

Native plugin — recommended

Installs straight into your client for the deepest integration: bili plugin install pi. Covers pi · omp · claude · codex · opencode · dsh · kimi · hermes · zcode.

Launcher — works for any agent

Wraps your client's command and injects bili automatically, zero config edits: bili pi, bili codex, bili claude — about twenty agents.

Generic proxy

Any client that accepts a custom endpoint works out of the box: point its base URL at http://localhost:8787/bili/<your upstream>.

terminal
npm install -g billion-context --prefix=~/.local
bili pi          # or: bili codex / claude / omp / opencode …

Connected? Type /acp in your agent for the live panel and /acp-cache for the token economics. Per-agent details, MITM mode and troubleshooting: the connect guide.

Peer-reviewable by anyone

Model-driven incremental hierarchical compression: training-free multi-generational context management for long-lived coding agents

The method behind the product, open-sourced under MIT inside the repository and updated as a living document. A 4.5-month production study across three hosts: 174,327 model calls, 18.76B cumulative input tokens, zero window violations.

Read the preprint