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
fix: preserve proxy compatibility exports
JerrettDavisdc79976d79d9
diff --git a/headroom/proxy/cost.py b/headroom/proxy/cost.pyindex 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 loggingimport importlib.util+import loggingfrom collections import dequefrom datetime import datetime, timedeltafrom typing import TYPE_CHECKING, Any@@ -40,6 +40,7 @@ def _get_litellm_module() -> Any | None:litellm = imported_litellmreturn 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.pyindex 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 jsonimport importlib.util+import jsonimport loggingimport osimport tempfilediff --git a/headroom/proxy/server.py b/headroom/proxy/server.pyindex 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: F401CostTracker, # 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: F401from headroom.proxy.helpers import (COMPRESSION_TIMEOUT_SECONDS, # noqa: F401MAX_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 LiteLLMBackendif LiteLLMBackend is None:- from headroom.backends.litellm import LiteLLMBackend as ImportedLiteLLMBackend+ from headroom.backends.litellm import (+ LiteLLMBackend as ImportedLiteLLMBackend,+ )LiteLLMBackend = ImportedLiteLLMBackend