A context-compression plugin for month-long single sessions (billions of tokens) and small context windows (a 100K context is enough), billion-context is all you need .

★ 7,524⑂ 621👁 19⑃ 3,566● 3,259▤ 208
TypeScriptNOASSERTIONCreated 2026-08-06
Download: v0.1.215v0.1.215 ↓0.1.2152026-11-15
+134
Daily
+2,010
Weekly
7,524
stars
621
forks
19
watchers
3,566
prs
3,259
issues
208
releases

README

billion-context

English | 中文 | 日本語

Context-compression plugin — billion-context is all you need.

small context windows (100K is enough) · 5× fewer tokens · month-long single sessions (billions of tokens) · high compression quality









npm install -g billion-context --prefix=~/.local



 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 



---

 Cache health at a glance: a healthy session keeps a 96–99% prefix-cache hit rate — compression itself costs ≤2%. Sustained lower? Check attribution with /acp or /acp-cache (see FAQ); usual causes, in order: upstream cache TTL expiry · model switch · a bili bug (please report) · other/unknown.

 Community

QQ Group:
1056132097 (full)
1108730198 (full)
1129868472 (open)

---

 📄 Paper / Preprint

- Model-Driven Incremental Hierarchical Compression: Training-Free Multi-Generational Context Management for Long-Lived Coding Agents (English, v0.2)

 📝 The paper itself is open-sourced under the MIT License as part of the codebase (paper/). It is a living document — anyone may edit it; improvements are welcome via pull request.

A production-scale longitudinal study: 4.5 months, three hosts, 174,327 model calls, 18.76B cumulative input tokens (~24.7B across all hosts), zero window violations on 204,800-token models, marathon sessions of 8,584–12,049 calls.

 📊 Independent Third-Party Benchmarks

- 1,500-Item Cross-Benchmark Evaluation (LongMemEval-S · ContextBench · MemoryAgentBench) (中文版) — head-to-head comparison of billion-context (v0.1.202) against full context and 3 RAG arms (bm25, embedding, embedding-rerank) with DeepSeek V4.1 Flash, Qwen3-Embedding-8B, Qwen3-Reranker-4B, and Pi Agent: 1 on ContextBench (0.3097 Utilized F1, -58.3% cost vs full), +16.6% over best RAG on LongMemEval-S (79.20% vs 62.60%, -71.1% independent-session cost vs full), and 100% survival on 1.48M-token MemoryAgentBench TTL (30× steady-state compression where full fails 199/199).

---

billion-context sits between any agent and its model API, rewriting Anthropic/OpenAI streams with acp-kernel compression. The model decides when and what to compress into high-fidelity summaries — not a hard truncation limit.

 Why

Long coding sessions blow up context. Each provider charges per token, and once you pass the context window the session degrades or dies. billion-context compresses consumed conversation into layered summaries so you can run a single session for days — billions of tokens through one context window.

Unlike a host's built-in summarizer, compression here is incremental, reversible, and prefix-cache friendly: summaries are written in small ranges, can be decompressed on demand, and the cache prefix stays intact.

 How it works

!How it works

 Context-management tools

The proxy injects four context-management tools into the conversation; the model calls them itself as context grows, and the proxy executes compress serv

Top issues

#4599CI Control Center: Centralized CI Failure Handling & Status Sync (Comment all CI issues here; do not open new issues) | CI 总控: CI 失败集中处理与状态同步(所有 CI 问题在此评论, 勿开新 issue)225 comments · 2026-10-24#917Message Board | 留言板86 comments · 2026-09-17#6111POC: carry fold summaries as CCR placeholders (not inline prose) — weak-model confusion, from #602556 comments · 2026-11-10#2411[feature] Intercept TRAE Code (traecode) native compression commands, aligning with dsh native compression interception | [feature] 拦截 TRAE Code(traecode)的原生压缩指令,对齐 dsh 原生压缩拦截46 comments · 2026-10-08#3011[Bug] Fork of DSH branch clone: inheritance permanently abandoned by 409 SNAPSHOT_UNAVAILABLE — zero-fold clone triggers context_length_exceeded 400 on first turn | [Bug] DSH 分支克隆的 fork 继承被 409 SNAPSHOT_UNAVAILABLE 永久放弃:克隆零折叠,首轮即 context_length_exceeded …41 comments · 2026-10-13#6121DSH: select models for native compaction with safe same-session handoff39 comments · 2026-11-10#2438[resilience] Preflight compress/timeout loop on sustained mass fold-coverage loss has no graceful degrade37 comments · 2026-10-08#5643Snapshot-Centric Compression Foundation: Single-Row Table as Source of Truth + Compression = Insert/Delete/Update Events | Snapshot中心化的压缩底座:单行表真源 + 压缩=对表的增删改事件(非增量车道,#5652/v6 线定位纠正)33 comments · 2026-11-04

Discussions

Latest release

v0.1.215 v0.1.215 2026-11-15
What's Changed
 [PR] gate: fix upstream recorder leak causing real model gate deadlock (pipe inheritance) | gate: 修上游 recorder 泄漏导致真模型门禁卡死(管道继承) by @ranxianglei in https://github.com/ranxianglei/billion-context/pull/6671
 [PR] chore(branch): land 40 single-purpose fixes as one history-preserving batch (wave 5) by @ranxianglei in https://github.com/ranxianglei/billion-context/pull/6677
 [PR] fix: map search evidence offsets back to original Unicode text by @Afloat16 in https://github.com/ranxianglei/billion-context/pull/6494
 [PR] fix: interpret cache-diff byte offsets in original text coordina

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON