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.

chore(providers): remove dead provider and model helpers (#4078)

Tejas Chopra688b327039e4
diff --git a/headroom/models/config.py b/headroom/models/config.py
index 2ffb0f893..b822706b8 100644
--- a/headroom/models/config.py
+++ b/headroom/models/config.py
@@ -106,40 +106,6 @@ class MLModelConfig:
"""
return self._memory_estimates.get(model_name, 100)
- def total_memory_estimate(self) -> int:
- """Get total estimated memory if all configured models are loaded.
-
- Returns:
- Total estimated memory in MB.
- """
- return (
- self.get_memory_estimate(self.sentence_transformer)
- + self.get_memory_estimate(self.siglip)
- + self.get_memory_estimate(self.spacy)
- + self.get_memory_estimate(self.technique_router)
- )
-
# Singleton instance - import this to get defaults
ML_MODEL_DEFAULTS = MLModelConfig()
-
-
-# Convenience accessors for common use cases
-def get_default_embedding_model() -> str:
- """Get the default sentence transformer model name."""
- return ML_MODEL_DEFAULTS.sentence_transformer
-
-
-def get_default_embedding_dim() -> int:
- """Get the default embedding dimension."""
- return ML_MODEL_DEFAULTS.sentence_transformer_dim
-
-
-def get_default_spacy_model() -> str:
- """Get the default spaCy model name."""
- return ML_MODEL_DEFAULTS.spacy
-
-
-def get_default_siglip_model() -> str:
- """Get the default SIGLIP model name."""
- return ML_MODEL_DEFAULTS.siglip
diff --git a/headroom/providers/codex/model_metadata.py b/headroom/providers/codex/model_metadata.py
index f00f46405..54397a9ec 100644
--- a/headroom/providers/codex/model_metadata.py
+++ b/headroom/providers/codex/model_metadata.py
@@ -270,29 +270,6 @@ async def fetch_chatgpt_codex_model_entries(
return None
-async def fetch_chatgpt_codex_model_ids(
- http_client: CodexModelRegistryHttpClient,
- headers: Mapping[str, str],
- requested_client_version: str | None,
- options: CodexModelRegistryOptions = CodexModelRegistryOptions(),
-) -> tuple[str, ...] | None:
- """Fetch Codex model slugs from ChatGPT, returning None when fallback should apply."""
- model_entries = await fetch_chatgpt_codex_model_entries(
- http_client,
- headers,
- requested_client_version,
- options,
- )
- if model_entries is None:
- return None
- return tuple(
- slug
- for entry in model_entries
- for slug in (entry.get("slug"),)
- if isinstance(slug, str) and slug
- )
-
-
async def fetch_chatgpt_codex_models_response(
http_client: CodexModelRegistryHttpClient,
headers: Mapping[str, str],
diff --git a/headroom/providers/litellm.py b/headroom/providers/litellm.py
index e02f3f683..3197a5f19 100644
--- a/headroom/providers/litellm.py
+++ b/headroom/providers/litellm.py
@@ -46,7 +46,6 @@ try:
litellm.set_verbose = False
from litellm import get_model_info as litellm_get_model_info
- from litellm import model_cost as litellm_model_cost
from litellm import token_counter as litellm_token_counter
LITELLM_AVAILABLE = True
@@ -54,7 +53,6 @@ except ImportError:
LITELLM_AVAILABLE = False
litellm = None # type: ignore[assignment]
litellm_token_counter = None # type: ignore[assignment]
- litellm_model_cost = None # type: ignore[assignment]
litellm_get_model_info = None # type: ignore[assignment]
diff --git a/headroom/providers/opencode/config.py b/headroom/providers/opencode/config.py
index 694d83f41..c1bbe6fcc 100644
--- a/headroom/providers/opencode/config.py
+++ b/headroom/providers/opencode/config.py
@@ -64,14 +64,6 @@ def headroom_provider_entry(port: int) -> dict[str, Any]:
}
-def _opencode_home_dir() -> Path:
- """Return the OpenCode home/config directory."""
- env_path = os.environ.get("OPENCODE_HOME", "").strip()
- if env_path:
- return Path(env_path).expanduser()
- return Path.home() / ".config" / "opencode"
-
-
def opencode_config_paths() -> tuple[Path, Path]:
"""Return the selected config and its canonical Headroom backup path."""
config_file = opencode_config_path()
@@ -134,17 +126,6 @@ def strip_opencode_headroom_blocks(content: str, *, remove_mcp: bool = True) ->
return content.strip()
-def _render_provider_block(port: int) -> str:
- """Render a Headroom provider block as a JSON comment-wrapped snippet."""
- provider = {"headroom": headroom_provider_entry(port)}
- lines = [
- _PROVIDER_MARKER_START,
- f'"provider": {json.dumps(provider, indent=2)},',
- _PROVIDER_MARKER_END,
- ]
- return "\n".join(lines)
-
-
def _strip_jsonc_comments(text: str) -> str:
"""Remove JSONC line and block comments while preserving quoted strings."""
output: list[str] = []
@@ -245,26 +226,6 @@ def _inject_key_into_json(data: dict[str, Any], key: str, value: Any) -> dict[st
return data
-def append_headroom_plugin(config: dict[str, object]) -> bool:
- """Append the optional OpenCode plugin entry if it is not already present."""
- plugin = config.get("plugin")
- if plugin is None:
- config["plugin"] = [HEADROOM_OPENCODE_PLUGIN]
- return True
-
- if not isinstance(plugin, list):
- return False
-
- for entry in plugin:
- if entry == HEADROOM_OPENCODE_PLUGIN:
- return False
- if isinstance(entry, list) and entry and entry[0] == HEADROOM_OPENCODE_PLUGIN:
- return False
-
- plugin.append(HEADROOM_OPENCODE_PLUGIN)
- return True
-
-
def inject_opencode_provider_config(port: int, *, keep_user_entries: bool = False) -> None:
"""Inject a Headroom model provider into OpenCode's config file.
diff --git a/tests/test_provider_codex_model_metadata.py b/tests/test_provider_codex_model_metadata.py
index 26f50c25e..00e1094c9 100644
--- a/tests/test_provider_codex_model_metadata.py
+++ b/tests/test_provider_codex_model_metadata.py
@@ -12,7 +12,7 @@ from headroom.providers.codex import (
)
from headroom.providers.codex.model_metadata import (
codex_model_registry_entry,
- fetch_chatgpt_codex_model_ids,
+ fetch_chatgpt_codex_model_entries,
normalize_codex_registry_headers,
synthetic_model_get_response,
synthetic_models_list_response,
@@ -113,13 +113,14 @@ async def test_codex_model_registry_fetch_returns_slugs() -> None:
client = FakeClient()
- model_ids = await fetch_chatgpt_codex_model_ids(
+ entries = await fetch_chatgpt_codex_model_entries(
client,
{"authorization": "Bearer token", "chatgpt-account-id": "acct"},
"0.135.0",
)
- assert model_ids == ("gpt-5.5", "gpt-5.4")
+ assert entries is not None
+ assert [entry["slug"] for entry in entries] == ["gpt-5.5", "gpt-5.4"]
assert client.calls == [
(
"https://chatgpt.com/backend-api/codex/models?client_version=0.135.0",
diff --git a/tests/test_providers_opencode_config.py b/tests/test_providers_opencode_config.py
index dcbc21573..142c7c185 100644
--- a/tests/test_providers_opencode_config.py
+++ b/tests/test_providers_opencode_config.py
@@ -11,7 +11,6 @@ from headroom.providers.opencode.config import (
HEADROOM_OPENCODE_PLUGIN,
_inject_key_into_json,
_parse_json_loose,
- append_headroom_plugin,
inject_opencode_provider_config,
opencode_config_paths,
snapshot_opencode_config_if_unwrapped,
@@ -477,24 +476,6 @@ def test_inject_provider_config_preserves_unrelated_top_level_keys(
assert "headroom" in config.get("provider", {})
-def test_append_headroom_plugin_adds_plugin_once() -> None:
- config: dict[str, object] = {"plugin": ["some-plugin"]}
-
- assert append_headroom_plugin(config) is True
- assert append_headroom_plugin(config) is False
-
- assert config["plugin"] == ["some-plugin", HEADROOM_OPENCODE_PLUGIN]
-
-
-def test_append_headroom_plugin_preserves_configured_tuple_entry() -> None:
- config: dict[str, object] = {
- "plugin": [[HEADROOM_OPENCODE_PLUGIN, {"proxyUrl": "http://127.0.0.1:8787"}]]
- }
-
- assert append_headroom_plugin(config) is False
- assert config["plugin"] == [[HEADROOM_OPENCODE_PLUGIN, {"proxyUrl": "http://127.0.0.1:8787"}]]
-
-
def test_inject_provider_config_no_crash_on_unwriteable_dir(
monkeypatch: pytest.MonkeyPatch,
) -> None: