billion-context

Self-hosted proxy for developers tired of restarting agent sessions: bring your own API key

Category
Developer tools
Audience
Developers

Updated

billion-context is an open-source context-compression proxy for AI coding agents: a program that sits between your agent and the model API it calls, so a session stops dying when the context window fills up. It is for developers who run agents like Claude Code, Codex, Cursor, Aider, OpenCode or Zed all day, keep losing the thread, and would rather not open a fresh chat every few hours. The project is written in TypeScript by a developer who goes by ranxianglei, is distributed under the name billion-context, and installs a command called bili.

What it does

Normally a long agent chat ends one of two ways: the agent hits a hard context cutoff, or the host app quietly truncates the oldest messages and the agent forgets what it was doing. billion-context replaces that with compression the model performs on its own history. It adds four tools to the conversation, compress, decompress, search_context and acp_status, and the model calls them to fold older stretches of the chat into layered summaries. The summaries are reversible: anything folded away can be decompressed again, or searched, when it turns out to matter.

The project's own description states the goal plainly: a 100K-token context is enough, roughly five times fewer tokens, and single sessions lasting a month. Those are the authors' claims, not an independent measurement.

The headline evidence is a production study published by the project itself: 4.5 months of use across three host applications, 174,327 model calls, and a cumulative token count in the billions (18.76 billion in their figure), with no context-limit violations. That is the vendor's own record of its own tool, nobody outside the project has reproduced it, and this channel does not run the tools it covers.

How it works

The proxy speaks the Anthropic and OpenAI request formats, so you point your agent at it instead of at the provider and it rewrites the request and response stream as it passes through. The README lists more than twenty supported hosts, including the ones named above plus pi and Kimi.

Two design details matter more than the compression ratio:

  • Compression is incremental. Summaries are written over small ranges rather than in one destructive pass, so history degrades gradually instead of being cut off.
  • The prompt prefix is left intact. That is what keeps provider prefix caching working, which is the usual reason rewriting a conversation gets expensive.

Getting started

The code lives at github.com/ranxianglei/billion-context and ships as the npm package billion-context with the bili command, so there is no separate release build or installer to hunt down. You need an agent that can be pointed at a custom API base URL, and your own model API key: nothing is bundled or hosted for you.

The honest cost picture, then, is that the proxy is free and open source while the intelligence behind it is not. You keep paying whichever provider you already pay, and because the model itself performs the compression, the summarising consumes calls of its own: the project's study counts 174,327 of them over 4.5 months. The saving the project claims is in total tokens, not in having no bill at all.

The repository does not list operating system, memory or GPU requirements, so treat it as a TypeScript service you run wherever Node runs, and read the README for current options before you trust a long session to it.

When to use it / when not

The catch is age. The repository was created on 2026-08-06 and was pushed to again on the day this entry was written, which makes it about ten weeks old, with 1,871 stars and 157 forks. Every impressive number attached to it comes from inside the project, and a proxy that rewrites your agent's conversation is a component you will notice when it misbehaves.

Use it instead of paying for a giant native context window, a million-token model for example, when your work is one long thread over a codebase and your current model is cheap but forgetful. Don't use it if your sessions are short enough that your agent's built-in auto-compaction already suffices, or if you want numbers verified by someone other than the author before putting new code in the path of every model call.

The people who should take billion-context seriously are the ones who already feel the problem: developers whose agent work is one continuous thread on a large codebase, who pay per token, and who restart sessions more often than they would like. For them the mechanism is sensible and the code is readable TypeScript they can inspect before trusting it. Everyone else can reasonably wait a few months and watch whether the month-long sessions hold up for people outside the project.

More in Developer tools

All of Developer tools →