Skip to content

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.

fix: preserve proxy compatibility exports

JerrettDavisdc79976d79d9
diff --git a/headroom/proxy/cost.py b/headroom/proxy/cost.py
index 6965152d9..d1bef3a1a 100644
--- a/headroom/proxy/cost.py
+++ b/headroom/proxy/cost.py
@@ -8,8 +8,8 @@ Extracted from server.py for maintainability.
from __future__ import annotations
-import logging
import importlib.util
+import logging
from collections import deque
from datetime import datetime, timedelta
from typing import TYPE_CHECKING, Any
@@ -40,6 +40,7 @@ def _get_litellm_module() -> Any | None:
litellm = imported_litellm
return litellm
+
logger = logging.getLogger("headroom.proxy")
# Provider-specific cache discount multipliers (what fraction of input price)
diff --git a/headroom/proxy/savings_tracker.py b/headroom/proxy/savings_tracker.py
index b41979fc8..9910d006b 100644
--- a/headroom/proxy/savings_tracker.py
+++ b/headroom/proxy/savings_tracker.py
@@ -7,8 +7,8 @@ survive proxy restarts and can be shared by multiple Headroom frontends.
from __future__ import annotations
-import json
import importlib.util
+import json
import logging
import os
import tempfile
diff --git a/headroom/proxy/server.py b/headroom/proxy/server.py
index 3e61e046e..2d79d1229 100644
--- a/headroom/proxy/server.py
+++ b/headroom/proxy/server.py
@@ -98,10 +98,10 @@ from headroom.proxy.cost import (
_CACHE_ECONOMICS, # noqa: F401
CostTracker, # noqa: F401
_summarize_transforms, # noqa: F401
+ build_prefix_cache_stats, # noqa: F401
+ build_session_summary, # noqa: F401
+ merge_cost_stats, # noqa: F401
)
-from headroom.proxy.cost import build_prefix_cache_stats as _build_prefix_cache_stats # noqa: F401
-from headroom.proxy.cost import build_session_summary as _build_session_summary # noqa: F401
-from headroom.proxy.cost import merge_cost_stats as _merge_cost_stats # noqa: F401
from headroom.proxy.helpers import (
COMPRESSION_TIMEOUT_SECONDS, # noqa: F401
MAX_COMPRESSION_CACHE_SESSIONS, # noqa: F401
@@ -144,6 +144,10 @@ from headroom.transforms import (
is_tree_sitter_available,
)
+_build_prefix_cache_stats = build_prefix_cache_stats
+_build_session_summary = build_session_summary
+_merge_cost_stats = merge_cost_stats
+
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
@@ -377,7 +381,9 @@ class HeadroomProxy(
try:
global LiteLLMBackend
if LiteLLMBackend is None:
- from headroom.backends.litellm import LiteLLMBackend as ImportedLiteLLMBackend
+ from headroom.backends.litellm import (
+ LiteLLMBackend as ImportedLiteLLMBackend,
+ )
LiteLLMBackend = ImportedLiteLLMBackend