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(proxy): cover enabled periodic TOIN stats startup (#1268)
wstczywb514695efdcb
diff --git a/tests/test_proxy_telemetry_env.py b/tests/test_proxy_telemetry_env.pyindex 489f8293b..37c1b0101 100644--- a/tests/test_proxy_telemetry_env.py+++ b/tests/test_proxy_telemetry_env.py@@ -114,3 +114,37 @@ class TestProxyPeriodicTOINStatsEnv:passassert requested is False++ def test_lifespan_schedules_periodic_toin_stats_when_enabled(self, monkeypatch):+ """Enabled periodic TOIN stats schedules the stats loop at startup."""+ monkeypatch.setenv("HEADROOM_SKIP_UPSTREAM_CHECK", "1")+ requested = False++ def fake_periodic_toin_stats():+ nonlocal requested+ requested = True++ async def noop():+ await asyncio.sleep(0)++ return noop()++ monkeypatch.setattr(+ "headroom.proxy.server._log_toin_stats_periodically",+ fake_periodic_toin_stats,+ )++ app = create_app(+ ProxyConfig(+ optimize=False,+ cache_enabled=False,+ rate_limit_enabled=False,+ cost_tracking_enabled=False,+ periodic_toin_stats_enabled=True,+ )+ )++ with TestClient(app):+ pass++ assert requested is True