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(proxy): label plain OpenAI chat traffic openai, not custom (#3912)
Tejas Chopra7df8bd87b547
diff --git a/headroom/proxy/handlers/openai.py b/headroom/proxy/handlers/openai.pyindex 06fc8150b..5b98bc102 100644--- a/headroom/proxy/handlers/openai.py+++ b/headroom/proxy/handlers/openai.py@@ -3646,7 +3646,7 @@ class OpenAIHandlerMixin:# other custom base is the shared "custom" bucket. Never derive the# label from the request-controlled hostname — see the review on #3759.openai_chat_outcome_provider = custom_chat_provider or (- CUSTOM_BASE_PROVIDER if upstream_base_url else "openai"+ CUSTOM_BASE_PROVIDER if custom_upstream_base_url else "openai")# Memory: Get user ID when memory is enabled. Reads `request.headers`diff --git a/tests/test_proxy_openai_cache_stability.py b/tests/test_proxy_openai_cache_stability.pyindex 3985c9247..0e536faa2 100644--- a/tests/test_proxy_openai_cache_stability.py+++ b/tests/test_proxy_openai_cache_stability.py@@ -20,6 +20,7 @@ from opentelemetry.sdk.metrics.export import InMemoryMetricReaderfrom headroom.backends.base import BackendResponsefrom headroom.observability import HeadroomOtelMetrics, reset_otel_metrics, set_otel_metrics+from headroom.proxy.handlers.openai import _openai_rate_limit_keyfrom headroom.proxy.server import ProxyConfig, create_appfrom tests.test_observability_metrics import _collect_metrics@@ -1297,7 +1298,7 @@ def test_openai_chat_custom_base_flood_cannot_grow_the_provider_set("""Headroom's own limiter, refusing only ``limited_auth``."""async def check_request(self, key: str = "default") -> tuple[bool, float]:- return key != limited_auth, 1.0+ return key != _openai_rate_limit_key({"authorization": limited_auth}), 1.0async def check_tokens(self, key: str, tokens: int) -> tuple[bool, float]:return True, 0.0