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): don't fail startup when libc_ver() can't read the interpreter (#4519)
Muhammad Musa28172a921f4e
diff --git a/headroom/proxy/server.py b/headroom/proxy/server.pyindex 310c19b42..2e97c8404 100644--- a/headroom/proxy/server.py+++ b/headroom/proxy/server.py@@ -2004,7 +2004,12 @@ class HeadroomProxy(if raw not in ("1", "true", "yes", "on"):import platform- libc, version = platform.libc_ver()+ try:+ libc, version = platform.libc_ver()+ except OSError:+ # libc_ver() reads sys.executable; Microsoft Store Python's+ # python.exe is an app-execution alias that can't be opened.+ libc, version = "", ""if libc == "glibc":try:major, minor = (int(part) for part in version.split(".")[:2])diff --git a/tests/test_proxy/test_kompress_background_warmup.py b/tests/test_proxy/test_kompress_background_warmup.pyindex d03e61372..98dcff7d2 100644--- a/tests/test_proxy/test_kompress_background_warmup.py+++ b/tests/test_proxy/test_kompress_background_warmup.py@@ -67,6 +67,19 @@ def test_skipped_on_the_glibc_family_that_crashes(monkeypatch: pytest.MonkeyPatcassert not kompress.preloaded.wait(0.2)+def test_unreadable_interpreter_does_not_fail_startup(monkeypatch: pytest.MonkeyPatch) -> None:+ """Microsoft Store Python's python.exe can't be opened, so libc_ver() raises."""++ def _raise() -> tuple[str, str]:+ raise OSError(22, "Invalid argument")++ monkeypatch.setattr("platform.libc_ver", _raise)+ monkeypatch.delenv("PYTEST_CURRENT_TEST", raising=False)+ kompress = _Kompress()+ assert HeadroomProxy._start_kompress_background_warmup(_proxy_with(kompress)) is True+ assert kompress.preloaded.wait(5)++def test_env_switch_wins_both_ways(monkeypatch: pytest.MonkeyPatch) -> None:monkeypatch.setattr("platform.libc_ver", lambda: ("glibc", "2.17"))monkeypatch.setenv("HEADROOM_KOMPRESS_WARMUP", "1")