# Billion-context plugin for long sessions

> Compresses chat history so AI sessions can run for weeks.

- **What it does:** Shrinks the history your AI keeps during a chat so it uses far fewer tokens. That lets you keep one coding session going for weeks without running out of room.
- **Agents:** Claude Code and Codex (through orbit-connect), Claude and ChatGPT (through the Orbit connector)
- **Install:** `npx -y --loglevel=error orbit-connect@0.3.33 install skl_44bf92228a9e42f24114113e`
- **Creator:** @saad.b.ai on Instagram
- **Reach:** Creators' posts about it have 1,883 views
- **Safety:** Checked by Orbit: use with care. Global install of unpinned third-party npm code processing session data
- **Last updated:** 2026-11-14
- **Page:** https://orbitinbox.app/s/billion-context-plugin-for-long-sessions

## Skill

---
name: billion-context-setup
description: Use when a long coding session is running out of context or burning tokens: install and run the billion-context compression proxy.
---

# billion-context setup

## What this does
Installs `billion-context`, a context-compression proxy that 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 layered summaries, so one session can keep running for weeks.

## When to use
- Long coding sessions blow up context or die once you pass the context window.
- You want far fewer tokens while keeping a single session alive.

## How to run it
1. Install with a user-level prefix (no sudo):
   `npm install -g billion-context --prefix=~/.local`
   The `bili` command lands in `~/.local/bin`; if it is not on PATH, add `export PATH="$HOME/.local/bin:$PATH"`.
2. Pick ONE lane:
   - **Native plugin:** `bili plugin install <client>` (pi, omp, opencode, dsh, kimi, hermes, zcode), then start the client as usual — no launcher, no env vars, no URL edits. Undo with `bili plugin remove <client>`.
   - **Launcher (config-free):** `bili <client>` (e.g. `bili claude`, `bili codex`, `bili pi`) — brings up the proxy and the client together; no real config file is ever touched.
   - **URL change:** run `bili`, then prefix the client's existing baseURL with `http://localhost:8787/bili/`:
     `client baseURL before: https://api.openai.com/v1`
     `client baseURL after:  http://localhost:8787/bili/https://api.openai.com/v1`
   - **Claude Code marketplace:** `/plugin marketplace add ranxianglei/billion-context`, `/plugin install billion-context@billion-context`, then `/billion-context:bili-setup`.
3. Verify:
   `curl -s http://localhost:8787/__bili/health` → `{"ok":true,"upstream":"https://api.anthropic.com"}`
   `curl -s http://localhost:8787/__bili/stats`
   Send one message and watch `~/.local/state/billion-context/bili.log` for a `processTurn` line and, once the conversation grows, `[acp-usage] round N input=X cached=Y (cache hit Z%)` plus a `compress` event.
4. Four context-management tools are injected for the model: `compress` (fold a message range into a summary), `decompress` (restore a range), `search_context` (keyword search over summaries and visible messages), `acp_status` (context-usage overview).
5. Check cache health with `/acp-cache`: a healthy session keeps a 95–97% prefix-cache hit rate — compression itself costs ≤2%.

## Cautions
- Native plugin mode is **mutually exclusive** with the standalone in-process extensions (`billion-context-pi`, `opencode-acp`) — both active means double compression. The installer swaps entries and snapshots the original config to `.bili-bak`.
- The proxy has **no authentication**: keep it on loopback, and only use `bili --host 0.0.0.0` on a trusted network.
- Every mode reverses cleanly: `bili plugin remove <client>`, or stop using the launcher command / env vars / `/bili/` prefix.

## Output
Report the lane chosen, the exact commands run, the health and stats results, and the first cache-hit line observed in the log.

Credit: Based on public content by saad.b.ai, packaged by Orbit.

Shared by @saad.b.ai, credited on Orbit.