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(router): log the ONNX fallbacks at info instead of warning (#4535)
Tejas Chopradb30d82dfffd
diff --git a/headroom/_ort.py b/headroom/_ort.pyindex 97736eaa5..27996b2ae 100644--- a/headroom/_ort.py+++ b/headroom/_ort.py@@ -138,7 +138,10 @@ def _resolve_and_pin() -> str | None:installed = _installed_ort_version()if installed is not None and installed < _MIN_RUST_ORT_API_VERSION:- logger.warning(+ # By design on Intel macOS, where the proxy extra pins onnxruntime+ # <1.24 (no newer x86_64 wheels): Python detection is the supported+ # path there, so this is information, not a warning.+ logger.info("onnxruntime %d.%d exposes an older C API than Rust detection ""requires (1.24+); leaving %s unset and using Python detection",*installed,diff --git a/headroom/transforms/content_router.py b/headroom/transforms/content_router.pyindex 708a68cb3..87e06c4cc 100644--- a/headroom/transforms/content_router.py+++ b/headroom/transforms/content_router.py@@ -1350,8 +1350,12 @@ def _detect_content(content: str) -> DetectionResult:from headroom._ort import rust_ort_runtime_compatibleif not rust_ort_runtime_compatible():+ # Expected on every install without the proxy extra's ONNX Runtime+ # (plain ``pip install headroom-ai``): the pure-Python detector is the+ # supported path there, so this is information, not a warning. The+ # circuit breaker above makes it fire once per process._detect_native_unhealthy = True- logger.warning(+ logger.info("Native content detection requires ONNX Runtime 1.24+; ""using pure-Python detection for this process.")diff --git a/tests/test_transforms/test_ort_dylib.py b/tests/test_transforms/test_ort_dylib.pyindex bb6c5aa55..ce3acfbea 100644--- a/tests/test_transforms/test_ort_dylib.py+++ b/tests/test_transforms/test_ort_dylib.py@@ -11,6 +11,7 @@ monkeypatched so every branch runs on any CI OS.from __future__ import annotationsimport json+import loggingimport osimport subprocessimport sys@@ -86,10 +87,14 @@ def test_incompatible_package_is_not_pinned(monkeypatch, tmp_path, caplog):capi.mkdir(parents=True)(capi / "libonnxruntime.so.1.23.2").write_bytes(b"old")_fake_spec_for(monkeypatch, pkg)+ caplog.set_level(logging.INFO, logger=_ort.logger.name)assert _ort.ensure_ort_dylib_pinned() is Noneassert not _ort.rust_ort_runtime_compatible()- assert "older C API" in caplog.text+ older = [r for r in caplog.records if "older C API" in r.getMessage()]+ assert len(older) == 1+ # Supported configuration (Intel macOS pins onnxruntime <1.24): not a warning.+ assert older[0].levelno == logging.INFOdef test_content_router_bypasses_native_detector_for_incompatible_ort(monkeypatch, caplog):@@ -98,12 +103,21 @@ def test_content_router_bypasses_native_detector_for_incompatible_ort(monkeypatcmonkeypatch.setenv("HEADROOM_DETECT_BACKEND", "rust")monkeypatch.setattr(_ort, "rust_ort_runtime_compatible", lambda: False)monkeypatch.setattr(router, "_detect_native_unhealthy", False)+ caplog.set_level(logging.INFO, logger=router.logger.name)result = router._detect_content('{"safe": true}')assert result.content_type.value.startswith("json")assert router._detect_native_unhealthy is True- assert "requires ONNX Runtime 1.24+" in caplog.text+ fallback = [r for r in caplog.records if "requires ONNX Runtime 1.24+" in r.getMessage()]+ assert len(fallback) == 1+ # A base install has no ONNX Runtime by design; the fallback is the+ # supported path there, so it must not surface as a warning on first import.+ assert fallback[0].levelno == logging.INFO++ caplog.clear()+ router._detect_content('{"safe": true}')+ assert "requires ONNX Runtime 1.24+" not in caplog.textdef test_pins_to_package_capi_dll(monkeypatch, tmp_path):