How ranxianglei/billion-context works
billion-context is a context-compression proxy and agent integration layer. An agent sends model traffic through the proxy; the proxy processes the conversation with acp-kernel’s incremental compression, exposes model-invoked context tools, forwards requests to a compatible model API, and rewrites streaming responses. Client-specific adapters and launch/MITM support provide alternative ways to route traffic. Session state and content support long-lived conversations; a web interface exposes session and operational views. The README documents the core workflow and tools; sampled source confirms the loop, protocol adapters, configuration, and selected integrations, but not every subsystem’s wiring.
Main entry points: server.ts Proxy server · core.ts Compression loop · api.ts Web API · index.ts Protocol adapters
Components 20
Proxy entry
- CLI dispatcher
src/cli.ts - Proxy server
src/server.ts
Context management
- Compression loop
src/loop/core.ts - Protocol adapters
src/loop/index.ts - Context tools
src/compress-tool.ts
Client integrations
- Native agent plugins
src/agent - Client launchers
src/launcher.ts - TLS MITM routing
src/mitm.ts - Hermes plugin
hermes-plugin/__init__.py
Session and operations
- Session state
src/session.ts - Content store
src/store.ts - Proxy configuration
src/config.ts - Window resolution
src/server/context-window.ts
Web interface
- Web API
src/web/api.ts - Session views
src/web/sessions-data.ts - Web interface
src/web/index.ts - Log queries
src/web/logs-query.ts
Other components
- Coding agent
- Model API
- acp-kernel
Connections 21
- Coding agent → Proxy server: sends requests
- CLI dispatcher → Proxy server: starts
- Proxy server → Compression loop: processes turns
- Proxy server → Protocol adapters: selects protocol
- Protocol adapters → Compression loop: adapts streams
- Compression loop → acp-kernel: compresses context
- Compression loop → Context tools: executes tools
- Proxy server → Model API: forwards requests
- Model API → Proxy server: streams responses
- Proxy server → Session state: updates state
- Proxy server → Content store: adopts content store
- Proxy server → Proxy configuration: resolves routes
- Proxy server → Window resolution: resolves limits
- Native agent plugins → Proxy server: calls tool endpoints
- Client launchers → Proxy server: routes client traffic
- TLS MITM routing → Proxy server: routes intercepted traffic
- Hermes plugin → Proxy server: forwards tool calls
- Proxy server → Web API: serves admin API
- Web API → Session views: builds session views
- Web API → Log queries: queries logs
- Web interface → Web API: requests views