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
test: align savings schema assertions
JerrettDavisd50c73f2a178
diff --git a/tests/test_proxy_project_savings.py b/tests/test_proxy_project_savings.pyindex c39884aac..e32fed007 100644--- a/tests/test_proxy_project_savings.py+++ b/tests/test_proxy_project_savings.py@@ -257,7 +257,7 @@ def test_funnel_attributes_savings_from_context_and_stats_exposes_them(tmp_path,assert stats["persistent_savings"]["projects_limit"] == DEFAULT_MAX_PROJECTShistory = client.get("/stats-history").json()- assert history["schema_version"] == 4+ assert history["schema_version"] == 5assert history["projects"]["ctx-project"]["requests"] == 1diff --git a/tests/test_proxy_savings_history.py b/tests/test_proxy_savings_history.pyindex a7e4acec7..851cbd827 100644--- a/tests/test_proxy_savings_history.py+++ b/tests/test_proxy_savings_history.py@@ -125,7 +125,7 @@ def test_savings_tracker_sanitizes_legacy_state_and_applies_retention(tmp_path):)snapshot = tracker.snapshot()- assert snapshot["schema_version"] == 4+ assert snapshot["schema_version"] == 5assert snapshot["lifetime"] == {"requests": 0,"tokens_saved": 30,@@ -1100,7 +1100,7 @@ def test_stats_history_persists_across_restarts_and_stats_stays_compatible(tmp_phistory = client.get("/stats-history")assert history.status_code == 200history_data = history.json()- assert history_data["schema_version"] == 4+ assert history_data["schema_version"] == 5assert history_data["storage_path"] == str(savings_path)assert history_data["lifetime"]["tokens_saved"] == 40assert history_data["lifetime"]["total_input_tokens"] == 120@@ -1659,7 +1659,7 @@ def test_v3_state_without_cache_fields_loads_clean_and_saves_v4(tmp_path):timestamp="2026-07-02T00:00:00Z",)persisted = json.loads(path.read_text(encoding="utf-8"))- assert persisted["schema_version"] == 4+ assert persisted["schema_version"] == 5assert persisted["lifetime"]["cache_read_tokens"] == 5assert persisted["lifetime"]["tokens_saved"] == 42181diff --git a/tests/test_savings_ledger_before_forwarded.py b/tests/test_savings_ledger_before_forwarded.pyindex 45096a31b..52a10a133 100644--- a/tests/test_savings_ledger_before_forwarded.py+++ b/tests/test_savings_ledger_before_forwarded.py@@ -16,6 +16,9 @@ class _FakeSavingsTracker:def record_request(self, **kwargs: Any) -> None:pass+ def record_lifetime_request(self, **kwargs: Any) -> None:+ pass+class _FakeOtelMetrics:def record_proxy_request(self, **kwargs: Any) -> None: