boxmoe_header_banner_img

Hello! 欢迎来到阿虪的开发世界~

加载中

文章导读

billion-context:给 Agent 接上上下文压缩,100K 窗口跑月级长会话


avatar
阿虪 8 11 月, 2026 136
billion-context

中文版

billion-context(GitHub:https://github.com/ranxianglei/billion-context ,2026-08-06 创建,今晨抓取时已 4,611★,日榜单日涨 191★)是一个上下文压缩插件:坐在任意 agent 与模型 API 之间,让一个会话跑上一个月、累计几十亿 token,而不用换大窗口。

它的工作方式是做一个代理:你把 agent 的 base URL 指到它,它解析请求(Anthropic 或 OpenAI 格式)、对对话做压缩,再把请求转发给真正的模型 API,并改写流式响应。关键设计是压缩的决定权在模型手里——模型自己决定何时、把哪一段对话折叠成高保真摘要,而不是到上限就硬截断;压缩是增量、可逆、且对前缀缓存友好的:摘要按小段写、需要时能解压还原、缓存前缀保持完整。README 的口号是“100K 上下文就够了,省 5 倍 token”。它向对话里注入四个上下文管理工具:compress(把一段消息折叠成摘要)、decompress(需要精确细节时还原)、search_context(在摘要与可见消息里关键词搜索)、acp_status(上下文用量总览)。

支持的客户端很广:Claude Code、Codex、OpenCode、pi、Gemini CLI、Kimi、Qwen Code、Copilot CLI、deepseek-harness(dsh)、TRAE、CodeBuddy 等二十多种。安装用 npm install -g billion-context,之后可以原生插件、启动器(bili claude、bili codex、bili dsh……)或改 URL 前缀三种方式接入。README 还附了一篇开放的论文与第三方评测:在 ContextBench 上拿了第一(利用 F1 0.3097,成本比全上下文低 58.3%),在 LongMemEval-S 上比最优 RAG 高 16.6%,在 148 万 token 的 MemoryAgentBench 存活率 100%。许可证是 MIT 附加一条署名要求:能让用户看到或接触到它的产品或服务,需要在使用处注明用了 billion-context 并链回仓库。

为什么值得了解

  • 长会话爆上下文是每个重度用 agent 的人都会撞上的墙:按 token 计费的模型,窗口一满会话就退化甚至死掉;这个项目把“压缩”做成代理层,而不是让每个宿主自己实现
  • “模型自己决定压什么、什么时候压”比固定规则高明:摘要的质量取决于判断力,而判断力恰恰是模型最擅长的部分;可逆、可搜索的设计也留了后路
  • 对在意成本的人很直接:省 5 倍 token 就是省 5 倍账单,100K 的小窗口就能跑月级会话;中文作者、QQ 群活跃,国内用户遇到问题也好找人问

English Version

billion-context (GitHub: https://github.com/ranxianglei/billion-context , created 2026-08-06, 4,611 stars at this morning’s fetch, up 191 stars today on the daily trending list) is a context-compression plugin: it sits between any agent and the model API and lets a single session run for a month, pushing billions of tokens through one context window, without needing a bigger window.

It works as a proxy: you point your agent’s base URL at it, it parses the request (Anthropic or OpenAI shape), compresses the conversation, forwards the request to the real model API and rewrites the streaming response. The key design is that the model decides when and what to compress into high-fidelity summaries — not a hard truncation limit when the window fills. Compression is incremental, reversible and prefix-cache friendly: summaries are written in small ranges, can be decompressed on demand, and the cache prefix stays intact. The README’s motto: “a 100K context is enough, 5× fewer tokens.” It injects four context-management tools into the conversation: compress (fold a message range into a detailed summary), decompress (restore a range when exact details are needed again), search_context (keyword search over compressed summaries and visible messages) and acp_status (a context-usage overview).

It supports a wide range of clients: Claude Code, Codex, OpenCode, pi, Gemini CLI, Kimi, Qwen Code, Copilot CLI, deepseek-harness (dsh), TRAE, CodeBuddy and twenty more. Install with npm install -g billion-context, then connect as a native plugin, via a launcher (bili claude, bili codex, bili dsh, …) or by changing the URL prefix. The README also links an open paper and third-party benchmarks: #1 on ContextBench (0.3097 Utilized F1, −58.3% cost vs full context), +16.6% over the best RAG arm on LongMemEval-S, and 100% survival on the 1.48M-token MemoryAgentBench. It is MIT licensed plus one attribution term: any product or service whose users can see or interact with it must state that it uses billion-context, with a link back to the repository.

Why it’s worth knowing

  • Blowing up context in a long session is a wall every heavy agent user hits: with per-token billing, once the window fills the session degrades or dies; this project turns compression into a proxy layer instead of making every host reimplement it
  • “The model itself decides what to compress and when” is smarter than a fixed rule: summary quality depends on judgement, and judgement is exactly what models are best at; the reversible, searchable design also leaves a way back
  • For anyone watching costs it is direct: 5× fewer tokens means 5× smaller bills, and a 100K window can carry a month-long session; the author is Chinese with an active QQ community, so domestic users can find help easily


评论(0)

查看评论列表

暂无评论


发表评论

表情 颜文字

插入代码