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(ci): resolve mypy no-any-return and ruff formatting
Garm4a8d9812cfa3
diff --git a/headroom/telemetry/context.py b/headroom/telemetry/context.pyindex 2b77c9533..a9546bb2a 100644--- a/headroom/telemetry/context.py+++ b/headroom/telemetry/context.py@@ -20,9 +20,7 @@ from typing import Anylogger = logging.getLogger(__name__)-_KNOWN_WRAP_AGENTS = frozenset(- {"claude", "copilot", "codex", "aider", "cursor", "openclaw"}-)+_KNOWN_WRAP_AGENTS = frozenset({"claude", "copilot", "codex", "aider", "cursor", "openclaw"})def _slug_from_agent_type(agent_type: str) -> str:@@ -99,7 +97,7 @@ def detect_stack(stats: dict[str, Any] | None = None) -> str:if total > 0:dominant, count = max(by_stack.items(), key=lambda kv: kv[1])if count / total >= 0.8:- return dominant+ return str(dominant)return "mixed"return "proxy"diff --git a/tests/test_telemetry_context.py b/tests/test_telemetry_context.pyindex df0cf6015..1d055a8c0 100644--- a/tests/test_telemetry_context.py+++ b/tests/test_telemetry_context.py@@ -24,31 +24,23 @@ class TestDetectInstallMode:assert detect_install_mode(8787) == "wrapped"def test_on_demand_when_no_env_and_no_manifest(self, monkeypatch):- monkeypatch.setattr(- "headroom.install.state.list_manifests", lambda: []- )+ monkeypatch.setattr("headroom.install.state.list_manifests", lambda: [])assert detect_install_mode(8787) == "on_demand"def test_persistent_when_manifest_matches_port(self, monkeypatch):manifest = SimpleNamespace(port=8787, profile="default")- monkeypatch.setattr(- "headroom.install.state.list_manifests", lambda: [manifest]- )+ monkeypatch.setattr("headroom.install.state.list_manifests", lambda: [manifest])assert detect_install_mode(8787) == "persistent"def test_on_demand_when_manifest_port_mismatches(self, monkeypatch):manifest = SimpleNamespace(port=9000, profile="other")- monkeypatch.setattr(- "headroom.install.state.list_manifests", lambda: [manifest]- )+ monkeypatch.setattr("headroom.install.state.list_manifests", lambda: [manifest])assert detect_install_mode(8787) == "on_demand"def test_wrapped_takes_precedence_over_manifest(self, monkeypatch):monkeypatch.setenv("HEADROOM_AGENT_TYPE", "codex")manifest = SimpleNamespace(port=8787, profile="default")- monkeypatch.setattr(- "headroom.install.state.list_manifests", lambda: [manifest]- )+ monkeypatch.setattr("headroom.install.state.list_manifests", lambda: [manifest])assert detect_install_mode(8787) == "wrapped"def test_manifest_crash_falls_back_to_on_demand(self, monkeypatch):