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
refactor(evals): deprecate unused EvalSuite.add_case and CompressionEvaluator.evaluate_suite (#4087)
Tejas Chopra9b42fcc4fcf5
diff --git a/headroom/evals/core.py b/headroom/evals/core.pyindex 8fb7416f2..6a5c07a91 100644--- a/headroom/evals/core.py+++ b/headroom/evals/core.py@@ -8,6 +8,7 @@ from __future__ import annotationsimport jsonimport time+import warningsfrom collections.abc import Callable, Iteratorfrom dataclasses import dataclass, fieldfrom datetime import datetime@@ -200,6 +201,17 @@ class EvalSuite:self.cases: list[EvalCase] = cases or []def add_case(self, case: EvalCase) -> None:+ """Append a case to the suite.++ .. deprecated:: 0.41.0+ Pass ``cases`` to the constructor, or append to ``suite.cases``.+ """+ warnings.warn(+ "EvalSuite.add_case is deprecated and will be removed in a future release; "+ "pass cases to EvalSuite(...) or append to suite.cases.",+ DeprecationWarning,+ stacklevel=2,+ )self.cases.append(case)def __len__(self) -> int:@@ -371,7 +383,17 @@ class CompressionEvaluator:Returns:Aggregated results with statistics++ .. deprecated:: 0.41.0+ Call ``evaluate_case`` per case, or use a runner from+ ``headroom.evals.runners``."""+ warnings.warn(+ "CompressionEvaluator.evaluate_suite is deprecated and will be removed in a future "+ "release; call evaluate_case per case or use a runner from headroom.evals.runners.",+ DeprecationWarning,+ stacklevel=2,+ )start_time = time.time()results: list[EvalResult] = []diff --git a/tests/test_evals_core_deprecations.py b/tests/test_evals_core_deprecations.pynew file mode 100644index 000000000..5a6692ed8--- /dev/null+++ b/tests/test_evals_core_deprecations.py@@ -0,0 +1,35 @@+"""Deprecated EvalSuite / CompressionEvaluator methods still work and warn."""++from __future__ import annotations++import warnings+from pathlib import Path++import pytest++from headroom.evals.core import CompressionEvaluator, EvalCase, EvalSuite+++def _case(case_id: str) -> EvalCase:+ return EvalCase(id=case_id, context="The answer is 42.", query="What is it?", ground_truth="42")+++def test_deprecated_methods_warn_and_still_work(tmp_path: Path) -> None:+ with warnings.catch_warnings():+ warnings.simplefilter("error", DeprecationWarning)+ suite = EvalSuite(name="s") # supported paths stay silent+ EvalSuite(name="t", cases=[_case("c0")]).to_jsonl(tmp_path / "suite.jsonl")++ with pytest.warns(DeprecationWarning, match="EvalSuite.add_case is deprecated"):+ suite.add_case(_case("c1"))+ assert [c.id for c in suite] == ["c1"]++ suite.cases.append(_case("c2"))+ evaluator = CompressionEvaluator(llm_fn=lambda context, query: "It is 42.")+ with pytest.warns(+ DeprecationWarning, match="CompressionEvaluator.evaluate_suite is deprecated"+ ):+ result = evaluator.evaluate_suite(suite)+ assert result.total_cases == 2+ assert result.passed_cases == 2+ assert [r.case_id for r in result.results] == ["c1", "c2"]