How compresr-ai/context-gateway works
Context Gateway is a local proxy between AI-agent clients and LLM APIs. Its main workflow accepts agent requests, applies configured context and tool optimizations, forwards requests to providers, and returns responses; preemptive summarization prepares compaction in the background. The repository also includes configuration, authentication, monitoring, and a browser dashboard. Several subsystem links are documented or visible in the source index, but unsampled implementations and dynamic wiring are not assumed.
Main entry points: handler.go HTTP gateway · tool_output.go Tool output pipes · adapters Provider adapters · manager.go Preemptive compaction
Components 16
Gateway runtime
- HTTP gateway
internal/gateway/handler.go - Provider adapters
internal/adapters - Provider auth
internal/auth
Context optimization
- Preemptive compaction
internal/preemptive/manager.go - Tool output pipes
internal/pipes/tool_output/tool_output.go - Tool search dispatch
internal/gateway/search_tool_handler.go - Context expansion
internal/gateway/expand_context_handler.go - Expanded content store
internal/store/store.go - Compression LLM client
external/llm.go
Operations
- Runtime configuration
internal/config/reloader.go - Usage monitoring
internal/monitoring - Dashboard handlers
internal/dashboard/handlers.go
Dashboard
- Dashboard interface
web/dashboard/src/App.tsx
Other components
- AI agent
- LLM API
- Compresr service
Connections 16
- AI agent → HTTP gateway: sends requests
README.md - HTTP gateway → Provider adapters: dispatches requests
internal/gateway/handler.go - HTTP gateway → Provider auth: uses auth
internal/gateway/handler.go - Provider adapters → LLM API: forwards requests
- HTTP gateway → Preemptive compaction: checks compaction
internal/gateway/handler.go - Preemptive compaction → Compression LLM client: summarizes context
- HTTP gateway → Tool output pipes: processes tool output
- HTTP gateway → Tool search dispatch: dispatches tool search
internal/gateway/search_tool_handler.go - HTTP gateway → Context expansion: handles expansion
internal/gateway/expand_context_handler.go - Context expansion → Expanded content store: reads content
internal/gateway/expand_context_handler.go - HTTP gateway → Runtime configuration: loads configuration
- HTTP gateway → Usage monitoring: records activity
internal/gateway/handler.go - HTTP gateway → Dashboard handlers: serves dashboard data
- Dashboard interface → Dashboard handlers: requests dashboard data
- Tool output pipes → Compresr service: compresses output
- Tool output pipes → Compression LLM client: uses LLM compression