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
docs(evals): add session probes section to evals README (#888)
Focused Instabilityb51cda10d776
diff --git a/headroom/cache/dynamic_detector.py b/headroom/cache/dynamic_detector.pyindex 0e85d13f7..44ce5a4ed 100644--- a/headroom/cache/dynamic_detector.py+++ b/headroom/cache/dynamic_detector.py@@ -770,8 +770,6 @@ class SemanticDetector:# Encode all sentencesif not sentences:return [], None- if self._model is None or self._exemplar_embeddings is None:- return [], self._load_error or "semantic detector is not initialized"try:import numpy as np@@ -779,6 +777,9 @@ class SemanticDetector:return [], "numpy not installed. Install with: pip install numpy"sentence_texts = [s[0] for s in sentences]+ if self._model is None or self._exemplar_embeddings is None:+ return [], self._load_error or "semantic detector is not initialized"+sentence_embeddings = self._model.encode(sentence_texts,convert_to_numpy=True,diff --git a/headroom/evals/README.md b/headroom/evals/README.mdindex fb8fb7153..1fd60cf42 100644--- a/headroom/evals/README.md+++ b/headroom/evals/README.md@@ -79,6 +79,28 @@ result = runner.run()save_reports(result, "eval_results/")```+## Session Probes (real recorded sessions)++The benchmark suites above prove the compressors in vitro. Session probes+measure what compression removed from YOUR real sessions, offline and with no+LLM or API key:++```bash+# 1. Record: run the proxy with recording enabled (opt-in; recordings contain+# full conversation content in plaintext and stay on this machine)+HEADROOM_PROBE_RECORD_DIR=~/.headroom/probe-recordings headroom proxy start++# 2. Use your agent through the proxy as normal, then score retention:+headroom evals probes --recordings ~/.headroom/probe-recordings+```++Probe targets are extracted from original tool results across three+dimensions — exact numerics, artifact trail (paths/URLs/hashes), error+evidence — and classified as retained (verbatim or surviving a format+conversion), recoverable (behind a CCR retrieval marker), or lost. The report+buckets retention by compression ratio and groups it per transform. Use+`--json-output report.json` for machine-readable results.+## Evaluation Tiers### Tier 1: Core Report Card (~$3, ~15 min)diff --git a/tests/test_cache/test_dynamic_detector.py b/tests/test_cache/test_dynamic_detector.pyindex 06d598d16..f9ae3bba8 100644--- a/tests/test_cache/test_dynamic_detector.py+++ b/tests/test_cache/test_dynamic_detector.py@@ -473,6 +473,21 @@ class TestSemanticDetector:# Should detect this as volatile/realtime# Depends on similarity threshold+ def test_missing_exemplar_embeddings_returns_warning(self):+ """Semantic detector reports unavailable state when embeddings are missing."""+ from headroom.cache.dynamic_detector import SemanticDetector++ detector = object.__new__(SemanticDetector)+ detector.config = DetectorConfig(tiers=["semantic"])+ detector._model = object()+ detector._exemplar_embeddings = None+ detector._load_error = None++ spans, warning = detector.detect("The current stock price changes every minute.")++ assert spans == []+ assert warning == "semantic detector is not initialized"+class TestIntegrationWithAllTiers:"""Integration tests using all available tiers."""