Context Gateway
Instant history compaction and context optimization for AI agents. Gateway sits between your AI agent and the LLM API, compressing conversation history in the background so you never wait.
View on GitHubQuick Start
1. Install (from GitHub)
curl -fsSL https://compresr.ai/install_gateway_cli | sh2. Launch Interactive Setup
context-gatewayOpens an interactive wizard to select your agent and configure settings.
3. Select Your Agent
Current supported agents:
Claude Code
OpenClaw
OpenCode
Custom
Works with any LLM provider including OpenAI, Anthropic, Ollama (local models), and Amazon Bedrock.
4. Configure
The interactive wizard will guide you through:
- API Keys: Configure your LLM provider keys (Anthropic, OpenAI, etc.)
- Compression Settings: Set trigger threshold for context compression (default: 75%)
- Optional: Enable Slack notifications for monitoring
Configuration is saved to ~/.config/context-gateway/.env
What You'll Notice
- No more waiting when conversation hits context limits
- Compaction happens instantly (summary was pre-computed in background)
- Check
logs/compaction.jsonlto see what's happening
How It Works
Context Gateway acts as a transparent proxy between your AI agent (Claude Code, Cursor, etc.) and the LLM API:
- Intercepts requests: All LLM API calls go through the gateway
- Background compression: As conversations grow, the gateway pre-computes compressed versions
- Instant compaction: When context limits are reached, compressed history is instantly applied
- Seamless experience: Your agent never knows the difference
Logs & Monitoring
The gateway creates detailed logs to help you understand what's happening:
logs/compaction.jsonlWhen and how conversations are compressed
logs/compression.jsonlDetailed compression metrics and results
logs/telemetry.jsonlRequest/response timing and performance data
Benefits
- Zero latency: Compression happens in the background, not on the critical path
- Transparent: Works with existing tools and workflows
- Cost savings: Reduce token usage by 30-70%
- Extended conversations: Never hit context limits
- Better quality: Agent retains more important context
Contributing
We welcome contributions! Please join our Discord to contribute.