Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
Python agentaianthropicclaude-codecompressioncontext-engineeringcontext-windowcursorfastapilangchainllmmcpopenaiprompt-engineeringproxypythonragtoken-optimizationtokenstypescript
Add dashboard UI and improve proxy observability
chopratejas1599821c3eb3
diff --git a/headroom/dashboard/__init__.py b/headroom/dashboard/__init__.pynew file mode 100644index 000000000..74010394d--- /dev/null+++ b/headroom/dashboard/__init__.py@@ -0,0 +1,12 @@+"""Headroom Dashboard - Real-time proxy monitoring UI."""++from pathlib import Path++DASHBOARD_DIR = Path(__file__).parent+TEMPLATES_DIR = DASHBOARD_DIR / "templates"+++def get_dashboard_html() -> str:+ """Load the dashboard HTML template."""+ template_path = TEMPLATES_DIR / "dashboard.html"+ return template_path.read_text()diff --git a/headroom/dashboard/templates/dashboard.html b/headroom/dashboard/templates/dashboard.htmlnew file mode 100644index 000000000..9e02420db--- /dev/null+++ b/headroom/dashboard/templates/dashboard.html@@ -0,0 +1,377 @@+<!DOCTYPE html>+<html lang="en" class="dark">+<head>+ <meta charset="UTF-8">+ <meta name="viewport" content="width=device-width, initial-scale=1.0">+ <title>Headroom Dashboard</title>+ <script src="https://cdn.tailwindcss.com"></script>+ <script src="https://unpkg.com/[email protected]"></script>+ <script src="https://unpkg.com/[email protected]/dist/cdn.min.js" defer></script>+ <script>+ tailwind.config = {+ darkMode: 'class',+ theme: {+ extend: {+ colors: {+ surface: '#1a1a1a',+ border: '#2a2a2a',+ accent: '#22d3ee',+ }+ }+ }+ }+ </script>+ <style>+ body { background: #0f0f0f; }+ .sparkline { stroke: #22d3ee; stroke-width: 1.5; fill: none; }+ .sparkline-area { fill: url(#sparkline-gradient); }+ @keyframes pulse-subtle { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }+ .pulse-live { animation: pulse-subtle 2s ease-in-out infinite; }+ </style>+</head>+<body class="text-gray-200 min-h-screen" x-data="dashboard()" x-init="init()">+ <!-- Header -->+ <header class="border-b border-border px-6 py-4 flex items-center justify-between">+ <div class="flex items-center gap-4">+ <h1 class="text-xl font-semibold tracking-tight">HEADROOM</h1>+ <span class="text-xs text-gray-500 font-mono" x-text="'v' + version"></span>+ </div>+ <div class="flex items-center gap-6">+ <div class="flex items-center gap-2">+ <span class="text-xs text-gray-500">Status</span>+ <span class="flex items-center gap-1.5">+ <span class="w-2 h-2 rounded-full pulse-live"+ :class="healthy ? 'bg-emerald-400' : 'bg-red-400'"></span>+ <span class="text-sm" x-text="healthy ? 'Healthy' : 'Error'"></span>+ </span>+ </div>+ <div class="text-xs text-gray-500">+ Updated <span x-text="lastUpdate"></span>+ </div>+ </div>+ </header>++ <main class="p-6 max-w-7xl mx-auto">+ <!-- Hero Metrics -->+ <div class="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">+ <!-- Requests -->+ <div class="bg-surface rounded-lg p-4 border border-border">+ <div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Requests</div>+ <div class="text-3xl font-light tabular-nums" x-text="formatNumber(stats.requests?.total || 0)"></div>+ <div class="mt-2 h-8">+ <svg class="w-full h-full" viewBox="0 0 100 32" preserveAspectRatio="none">+ <defs>+ <linearGradient id="sparkline-gradient" x1="0%" y1="0%" x2="0%" y2="100%">+ <stop offset="0%" style="stop-color:#22d3ee;stop-opacity:0.3"/>+ <stop offset="100%" style="stop-color:#22d3ee;stop-opacity:0"/>+ </linearGradient>+ </defs>+ <path class="sparkline-area" :d="getSparklineArea(requestHistory)"></path>+ <path class="sparkline" :d="getSparkline(requestHistory)"></path>+ </svg>+ </div>+ </div>++ <!-- Tokens Saved -->+ <div class="bg-surface rounded-lg p-4 border border-border">+ <div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Tokens Saved</div>+ <div class="flex items-baseline gap-2">+ <span class="text-3xl font-light tabular-nums text-accent" x-text="formatNumber(stats.tokens?.saved || 0)"></span>+ <span class="text-sm text-accent" x-text="(stats.tokens?.savings_percent || 0).toFixed(1) + '%'"></span>+ </div>+ <div class="mt-2 h-8">+ <svg class="w-full h-full" viewBox="0 0 100 32" preserveAspectRatio="none">+ <path class="sparkline-area" :d="getSparklineArea(savingsHistory)"></path>+ <path class="sparkline" :d="getSparkline(savingsHistory)"></path>+ </svg>+ </div>+ </div>++ <!-- Cost Saved -->+ <div class="bg-surface rounded-lg p-4 border border-border">+ <div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Cost Saved</div>+ <div class="flex items-baseline gap-2">+ <span class="text-3xl font-light tabular-nums text-accent" x-text="'$' + formatCost(stats.cost?.total_savings_usd || 0)"></span>+ </div>+ <div class="mt-3 text-xs text-gray-500">+ vs $<span x-text="formatCost(stats.cost?.total_cost_usd || 0)"></span> spent+ </div>+ </div>++ <!-- Headroom Overhead -->+ <div class="bg-surface rounded-lg p-4 border border-border">+ <div class="text-xs text-gray-500 uppercase tracking-wide mb-1">Headroom Overhead</div>+ <div class="flex items-baseline gap-2">+ <span class="text-3xl font-light tabular-nums" x-text="(stats.overhead?.average_ms || 0).toFixed(0) + 'ms'"></span>+ </div>+ <div class="mt-3 text-xs text-gray-500">+ Avg <span x-text="((stats.latency?.average_ms || 0) / 1000).toFixed(1)"></span>s total response time+ </div>+ </div>+ </div>++ <!-- Main Grid -->+ <div class="grid grid-cols-1 lg:grid-cols-3 gap-4 mb-6">+ <!-- Token Usage -->+ <div class="bg-surface rounded-lg p-4 border border-border">+ <div class="text-sm font-medium mb-4 text-gray-300">Token Usage</div>+ <div class="space-y-3">+ <div class="flex justify-between items-center">+ <span class="text-sm text-gray-400">Input Tokens</span>+ <span class="font-mono text-sm" x-text="formatNumber(stats.tokens?.input || 0)"></span>+ </div>+ <div class="flex justify-between items-center">+ <span class="text-sm text-gray-400">Output Tokens</span>+ <span class="font-mono text-sm" x-text="formatNumber(stats.tokens?.output || 0)"></span>+ </div>+ <div class="border-t border-border my-2"></div>+ <div class="flex justify-between items-center">+ <span class="text-sm text-gray-400">Original Size</span>+ <span class="font-mono text-sm" x-text="formatNumber(stats.tokens?.total_before_compression || 0)"></span>+ </div>+ <div class="flex justify-between items-center">+ <span class="text-sm text-gray-400">After Compression</span>+ <span class="font-mono text-sm" x-text="formatNumber(stats.tokens?.input || 0)"></span>+ </div>+ </div>+ </div>++ <!-- Providers -->+ <div class="bg-surface rounded-lg p-4 border border-border">+ <div class="text-sm font-medium mb-4 text-gray-300">Providers</div>+ <div class="space-y-2">+ <template x-for="(count, provider) in (stats.requests?.by_provider || {})" :key="provider">+ <div class="flex justify-between items-center">+ <span class="text-sm text-gray-400" x-text="provider"></span>+ <div class="flex items-center gap-2">+ <div class="w-24 h-1.5 bg-border rounded-full overflow-hidden">+ <div class="h-full bg-accent rounded-full"+ :style="'width: ' + getProviderPercent(count) + '%'"></div>+ </div>+ <span class="font-mono text-sm w-12 text-right" x-text="formatNumber(count)"></span>+ </div>+ </div>+ </template>+ <template x-if="Object.keys(stats.requests?.by_provider || {}).length === 0">+ <div class="text-sm text-gray-500 italic">No requests yet</div>+ </template>+ </div>+ </div>++ <!-- Performance -->+ <div class="bg-surface rounded-lg p-4 border border-border">+ <div class="text-sm font-medium mb-4 text-gray-300">Performance</div>+ <div class="space-y-3">+ <div class="flex justify-between items-center">+ <span class="text-sm text-gray-400">Headroom Overhead</span>+ <span class="font-mono text-sm" x-text="(stats.overhead?.average_ms || 0).toFixed(0) + 'ms avg'"></span>+ </div>+ <div class="flex justify-between items-center">+ <span class="text-sm text-gray-400">Overhead Range</span>+ <span class="font-mono text-sm" x-text="(stats.overhead?.min_ms || 0).toFixed(0) + ' - ' + (stats.overhead?.max_ms || 0).toFixed(0) + 'ms'"></span>+ </div>+ <div class="flex justify-between items-center">+ <span class="text-sm text-gray-400">Total Response Time</span>+ <span class="font-mono text-sm" x-text="((stats.latency?.average_ms || 0) / 1000).toFixed(1) + 's avg'"></span>+ </div>+ <div class="flex justify-between items-center">+ <span class="text-sm text-gray-400">Failed Requests</span>+ <span class="font-mono text-sm" x-text="stats.requests?.failed || 0"></span>+ </div>+ </div>+ </div>+ </div>++ <!-- Recent Requests Table -->+ <div class="bg-surface rounded-lg border border-border overflow-hidden">+ <div class="px-4 py-3 border-b border-border flex justify-between items-center">+ <span class="text-sm font-medium text-gray-300">Recent Requests</span>+ <span class="text-xs text-gray-500">Last 10</span>+ </div>+ <div class="overflow-x-auto">+ <table class="w-full text-sm">+ <thead>+ <tr class="text-left text-xs text-gray-500 uppercase tracking-wide">+ <th class="px-4 py-3 font-medium">Time</th>+ <th class="px-4 py-3 font-medium">Model</th>+ <th class="px-4 py-3 font-medium text-right">Input</th>+ <th class="px-4 py-3 font-medium text-right">Output</th>+ <th class="px-4 py-3 font-medium text-right">Saved</th>+ <th class="px-4 py-3 font-medium text-right">Cost</th>+ <th class="px-4 py-3 font-medium text-right">Latency</th>+ </tr>+ </thead>+ <tbody class="divide-y divide-border">+ <template x-for="req in (stats.recent_requests || [])" :key="req.request_id">+ <tr class="hover:bg-border/30 transition-colors">+ <td class="px-4 py-3 font-mono text-gray-400" x-text="formatTime(req.timestamp)"></td>+ <td class="px-4 py-3">+ <span class="px-2 py-0.5 bg-border rounded text-xs" x-text="truncateModel(req.model)"></span>+ </td>+ <td class="px-4 py-3 text-right font-mono" x-text="formatNumber(req.input_tokens_optimized)"></td>+ <td class="px-4 py-3 text-right font-mono" x-text="formatNumber(req.output_tokens || 0)"></td>+ <td class="px-4 py-3 text-right">+ <span class="text-accent font-mono" x-text="req.savings_percent.toFixed(0) + '%'"></span>+ </td>+ <td class="px-4 py-3 text-right font-mono text-gray-400" x-text="'$' + (req.estimated_cost_usd || 0).toFixed(4)"></td>+ <td class="px-4 py-3 text-right font-mono text-gray-400" x-text="(req.total_latency_ms || 0).toFixed(0) + 'ms'"></td>+ </tr>+ </template>+ <template x-if="(stats.recent_requests || []).length === 0">+ <tr>+ <td colspan="7" class="px-4 py-8 text-center text-gray-500 italic">+ No requests yet. Start using the proxy to see activity here.+ </td>+ </tr>+ </template>+ </tbody>+ </table>+ </div>+ </div>++ <!-- Budget Bar (if configured) -->+ <template x-if="stats.cost?.budget_limit_usd">+ <div class="mt-6 bg-surface rounded-lg p-4 border border-border">+ <div class="flex justify-between items-center mb-2">+ <span class="text-sm text-gray-400">Budget (<span x-text="stats.cost?.budget_period || 'daily'"></span>)</span>+ <span class="font-mono text-sm">+ $<span x-text="formatCost(stats.cost?.period_cost_usd || 0)"></span>+ / $<span x-text="formatCost(stats.cost?.budget_limit_usd || 0)"></span>+ </span>+ </div>+ <div class="w-full h-2 bg-border rounded-full overflow-hidden">+ <div class="h-full rounded-full transition-all duration-500"+ :class="getBudgetPercent() > 90 ? 'bg-red-400' : getBudgetPercent() > 70 ? 'bg-amber-400' : 'bg-accent'"+ :style="'width: ' + Math.min(getBudgetPercent(), 100) + '%'"></div>+ </div>+ </div>+ </template>+ </main>++ <!-- Footer -->+ <footer class="border-t border-border px-6 py-4 mt-8">+ <div class="flex justify-between items-center text-xs text-gray-500">+ <div>+ Press <kbd class="px-1.5 py-0.5 bg-border rounded text-gray-400">R</kbd> to refresh+ </div>+ <div>+ <a href="https://chopratejas.github.io/headroom/" target="_blank" class="hover:text-gray-300 transition-colors">Documentation</a>+ </div>+ </div>+ </footer>++ <script>+ function dashboard() {+ return {+ stats: {},+ healthy: true,+ version: '0.3.0',+ lastUpdate: 'never',+ requestHistory: [],+ savingsHistory: [],+ pollInterval: null,++ async init() {+ await this.fetchStats();+ this.pollInterval = setInterval(() => this.fetchStats(), 3000);++ // Keyboard shortcuts+ document.addEventListener('keydown', (e) => {+ if (e.key === 'r' || e.key === 'R') {+ this.fetchStats();+ }+ });+ },++ async fetchStats() {+ try {+ const [statsRes, healthRes] = await Promise.all([+ fetch('/stats'),+ fetch('/health')+ ]);++ this.stats = await statsRes.json();+ const health = await healthRes.json();+ this.healthy = health.status === 'healthy';+ this.version = health.version || '0.3.0';++ // Update history for sparklines+ this.requestHistory.push(this.stats.requests?.total || 0);+ this.savingsHistory.push(this.stats.tokens?.saved || 0);++ // Keep last 30 points+ if (this.requestHistory.length > 30) this.requestHistory.shift();+ if (this.savingsHistory.length > 30) this.savingsHistory.shift();++ this.lastUpdate = new Date().toLocaleTimeString();+ } catch (e) {+ console.error('Failed to fetch stats:', e);+ this.healthy = false;+ }+ },++ formatNumber(n) {+ if (n >= 1000000) return (n / 1000000).toFixed(1) + 'M';+ if (n >= 1000) return (n / 1000).toFixed(1) + 'k';+ return n.toString();+ },++ formatCost(n) {+ return n.toFixed(2);+ },++ formatTime(ts) {+ if (!ts) return '-';+ const d = new Date(ts);+ const now = new Date();+ const diff = (now - d) / 1000;+ if (diff < 60) return Math.floor(diff) + 's ago';+ if (diff < 3600) return Math.floor(diff / 60) + 'm ago';+ return d.toLocaleTimeString();+ },++ truncateModel(model) {+ if (!model) return '-';+ // Remove provider prefix and version suffix for display+ return model.replace(/^(anthropic\.|openai\.|bedrock\/)/, '')+ .replace(/-\d{8}$/, '')+ .substring(0, 20);+ },++ getProviderPercent(count) {+ const total = this.stats.requests?.total || 1;+ return Math.min((count / total) * 100, 100);+ },++ getBudgetPercent() {+ const limit = this.stats.cost?.budget_limit_usd || 1;+ const used = this.stats.cost?.period_cost_usd || 0;+ return (used / limit) * 100;+ },++ getSparkline(data) {+ if (!data || data.length < 2) return '';+ const min = Math.min(...data);+ const max = Math.max(...data);+ const range = max - min || 1;++ const points = data.map((v, i) => {+ const x = (i / (data.length - 1)) * 100;+ const y = 32 - ((v - min) / range) * 28;+ return `${x},${y}`;+ });++ return 'M' + points.join(' L');+ },++ getSparklineArea(data) {+ if (!data || data.length < 2) return '';+ const line = this.getSparkline(data);+ if (!line) return '';+ return line + ` L100,32 L0,32 Z`;+ }+ };+ }+ </script>+</body>+</html>diff --git a/headroom/proxy/server.py b/headroom/proxy/server.pyindex c22bb8aa1..abf7b2228 100644--- a/headroom/proxy/server.py+++ b/headroom/proxy/server.py@@ -44,7 +44,7 @@ try:import uvicornfrom fastapi import FastAPI, HTTPException, Request, Responsefrom fastapi.middleware.cors import CORSMiddleware- from fastapi.responses import JSONResponse, PlainTextResponse, StreamingResponse+ from fastapi.responses import HTMLResponse, JSONResponse, PlainTextResponse, StreamingResponseFASTAPI_AVAILABLE = Trueexcept ImportError:@@ -53,6 +53,7 @@ except ImportError:# Add parent to path for importssys.path.insert(0, str(Path(__file__).parent.parent.parent))+from headroom import __version__from headroom.backends import LiteLLMBackendfrom headroom.backends.base import Backendfrom headroom.cache.compression_feedback import get_compression_feedback@@ -78,6 +79,7 @@ from headroom.config import (RollingWindowConfig,SmartCrusherConfig,)+from headroom.dashboard import get_dashboard_htmlfrom headroom.providers import AnthropicProvider, OpenAIProviderfrom headroom.proxy.memory_handler import MemoryConfig, MemoryHandlerfrom headroom.telemetry import get_telemetry_collector@@ -676,8 +678,15 @@ class PrometheusMetrics:self.tokens_saved_total = 0self.latency_sum_ms = 0.0+ self.latency_min_ms = float("inf")+ self.latency_max_ms = 0.0self.latency_count = 0+ # Headroom overhead (optimization time only, excludes LLM)+ self.overhead_sum_ms = 0.0+ self.overhead_min_ms = float("inf")+ self.overhead_max_ms = 0.0+self.cost_total_usd = 0.0self.savings_total_usd = 0.0@@ -694,6 +703,7 @@ class PrometheusMetrics:cached: bool = False,cost_usd: float = 0,savings_usd: float = 0,+ overhead_ms: float = 0,):"""Record metrics for a request."""async with self._lock:@@ -709,8 +719,16 @@ class PrometheusMetrics:self.tokens_saved_total += tokens_savedself.latency_sum_ms += latency_ms+ self.latency_min_ms = min(self.latency_min_ms, latency_ms)+ self.latency_max_ms = max(self.latency_max_ms, latency_ms)self.latency_count += 1+ # Track Headroom overhead separately+ if overhead_ms > 0:+ self.overhead_sum_ms += overhead_ms+ self.overhead_min_ms = min(self.overhead_min_ms, overhead_ms)+ self.overhead_max_ms = max(self.overhead_max_ms, overhead_ms)+self.cost_total_usd += cost_usdself.savings_total_usd += savings_usd@@ -1654,14 +1672,51 @@ class HeadroomProxy:tokens_saved=tokens_saved,latency_ms=total_latency,cached=False,+ overhead_ms=optimization_latency,)+ cost_usd = None+ savings_usd = Noneif self.cost_tracker:cost_usd = self.cost_tracker.estimate_cost(model, optimized_tokens, output_tokens)+ original_cost = self.cost_tracker.estimate_cost(+ model, original_tokens, output_tokens+ )if cost_usd:self.cost_tracker.record_cost(cost_usd)+ if cost_usd and original_cost:+ savings_usd = original_cost - cost_usd+ self.cost_tracker.record_savings(savings_usd)++ # Log request+ if self.logger:+ self.logger.log(+ RequestLog(+ request_id=request_id,+ timestamp=datetime.now().isoformat(),+ provider="bedrock",+ model=model,+ input_tokens_original=original_tokens,+ input_tokens_optimized=optimized_tokens,+ output_tokens=output_tokens,+ tokens_saved=tokens_saved,+ savings_percent=(tokens_saved / original_tokens * 100)+ if original_tokens > 0+ else 0,+ estimated_cost_usd=cost_usd,+ estimated_savings_usd=savings_usd,+ optimization_latency_ms=optimization_latency,+ total_latency_ms=total_latency,+ tags=tags,+ cache_hit=False,+ transforms_applied=transforms_applied,+ request_messages=body.get("messages")+ if self.config.log_full_messages+ else None,+ )+ )return JSONResponse(status_code=backend_response.status_code,@@ -1909,6 +1964,7 @@ class HeadroomProxy:latency_ms=total_latency,cost_usd=cost_usd or 0,savings_usd=savings_usd or 0,+ overhead_ms=optimization_latency,)# Log request@@ -3676,14 +3732,51 @@ class HeadroomProxy:tokens_saved=tokens_saved,latency_ms=total_latency,cached=False,+ overhead_ms=optimization_latency,)+ cost_usd = None+ savings_usd = Noneif self.cost_tracker:cost_usd = self.cost_tracker.estimate_cost(model, optimized_tokens, output_tokens)+ original_cost = self.cost_tracker.estimate_cost(+ model, original_tokens, output_tokens+ )if cost_usd:self.cost_tracker.record_cost(cost_usd)+ if cost_usd and original_cost:+ savings_usd = original_cost - cost_usd+ self.cost_tracker.record_savings(savings_usd)++ # Log request+ if self.logger:+ self.logger.log(+ RequestLog(+ request_id=request_id,+ timestamp=datetime.now().isoformat(),+ provider="bedrock",+ model=model,+ input_tokens_original=original_tokens,+ input_tokens_optimized=optimized_tokens,+ output_tokens=output_tokens,+ tokens_saved=tokens_saved,+ savings_percent=(tokens_saved / original_tokens * 100)+ if original_tokens > 0+ else 0,+ estimated_cost_usd=cost_usd,+ estimated_savings_usd=savings_usd,+ optimization_latency_ms=optimization_latency,+ total_latency_ms=total_latency,+ tags=tags,+ cache_hit=False,+ transforms_applied=transforms_applied,+ request_messages=body.get("messages")+ if self.config.log_full_messages+ else None,+ )+ )if tokens_saved > 0:logger.info(@@ -5231,7 +5324,7 @@ def create_app(config: ProxyConfig | None = None) -> FastAPI:app = FastAPI(title="Headroom Proxy",description="Production-ready LLM optimization proxy",- version="1.0.0",+ version=__version__,)# CORS@@ -5260,7 +5353,7 @@ def create_app(config: ProxyConfig | None = None) -> FastAPI:async def health():return {"status": "healthy",- "version": "1.0.0",+ "version": __version__,"config": {"optimize": config.optimize,"cache": config.cache_enabled,@@ -5268,6 +5361,11 @@ def create_app(config: ProxyConfig | None = None) -> FastAPI:},}+ @app.get("/dashboard", response_class=HTMLResponse)+ async def dashboard():+ """Serve the Headroom dashboard UI."""+ return get_dashboard_html()+@app.get("/stats")async def stats():"""Get comprehensive proxy statistics.@@ -5284,6 +5382,23 @@ def create_app(config: ProxyConfig | None = None) -> FastAPI:# Calculate average latencyavg_latency_ms = round(m.latency_sum_ms / m.latency_count, 2) if m.latency_count > 0 else 0+ min_latency_ms = (+ round(m.latency_min_ms, 2)+ if m.latency_count > 0 and m.latency_min_ms != float("inf")+ else 0+ )+ max_latency_ms = round(m.latency_max_ms, 2) if m.latency_count > 0 else 0++ # Calculate Headroom overhead (optimization time only)+ avg_overhead_ms = (+ round(m.overhead_sum_ms / m.latency_count, 2) if m.latency_count > 0 else 0+ )+ min_overhead_ms = (+ round(m.overhead_min_ms, 2)+ if m.latency_count > 0 and m.overhead_min_ms != float("inf")+ else 0+ )+ max_overhead_ms = round(m.overhead_max_ms, 2) if m.latency_count > 0 else 0# Get compression store statsstore = get_compression_store()@@ -5323,8 +5438,15 @@ def create_app(config: ProxyConfig | None = None) -> FastAPI:},"latency": {"average_ms": avg_latency_ms,+ "min_ms": min_latency_ms,+ "max_ms": max_latency_ms,"total_requests": m.latency_count,},+ "overhead": {+ "average_ms": avg_overhead_ms,+ "min_ms": min_overhead_ms,+ "max_ms": max_overhead_ms,+ },"cost": proxy.cost_tracker.stats() if proxy.cost_tracker else None,"compression": {"ccr_entries": compression_stats.get("entry_count", 0),