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 GitHub

Quick Start

1. Install (from GitHub)

curl -fsSL https://compresr.ai/install_gateway_cli | sh

2. Launch Interactive Setup

context-gateway

Opens 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.jsonl to 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:

  1. Intercepts requests: All LLM API calls go through the gateway
  2. Background compression: As conversations grow, the gateway pre-computes compressed versions
  3. Instant compaction: When context limits are reached, compressed history is instantly applied
  4. Seamless experience: Your agent never knows the difference

Logs & Monitoring

The gateway creates detailed logs to help you understand what's happening:

logs/compaction.jsonl

When and how conversations are compressed

logs/compression.jsonl

Detailed compression metrics and results

logs/telemetry.jsonl

Request/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.

Support

Need help or have questions?