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(integrations): pin MCP server + LangChain evals to lossy+CCR path
chopratejas168800329b7c
diff --git a/headroom/integrations/mcp/server.py b/headroom/integrations/mcp/server.pyindex 9fe0b2626..e002a0001 100644--- a/headroom/integrations/mcp/server.py+++ b/headroom/integrations/mcp/server.py@@ -245,13 +245,23 @@ class HeadroomMCPCompressor:items_after = 0errors_preserved = 0- # Create SmartCrusher with profile settings+ # Create SmartCrusher with profile settings.+ #+ # The MCP integration emits JSON-shaped output that downstream+ # tool consumers parse and iterate. The PR4 lossless path+ # substitutes a CSV+schema STRING in place of arrays — great+ # for LLM prompts but wire-format-incompatible with consumers+ # that expect JSON arrays. So we keep the runtime MCP wrapper+ # on the lossy + CCR-Dropped path: the LLM sees row-level+ # subsets inline, with the full payload retrievable via CCR+ # cache. (Same retention semantics as Python's pre-PR4+ # SmartCrusher behavior.)smart_config = SmartCrusherConfig(enabled=True,min_tokens_to_crush=profile.min_tokens_to_compress,max_items_after_crush=profile.max_items,)- crusher = SmartCrusher(config=smart_config) # type: ignore[arg-type]+ crusher = SmartCrusher(config=smart_config, with_compaction=False) # type: ignore[arg-type]# Build messages for SmartCrusher (it expects conversation format)messages = [diff --git a/tests/test_integrations/langchain/test_evals.py b/tests/test_integrations/langchain/test_evals.pyindex 8da5862bf..c18b8b9f3 100644--- a/tests/test_integrations/langchain/test_evals.py+++ b/tests/test_integrations/langchain/test_evals.py@@ -30,13 +30,21 @@ def tokenizer():@pytest.fixturedef smart_crusher():- """Create SmartCrusher with default config."""+ """Create SmartCrusher with default config.++ These eval tests assert row-level retention semantics (errors+ preserved, anomalies preserved, schema unchanged in JSON shape).+ Those properties belong to the lossy + CCR-Dropped path, not+ the lossless path which substitutes a CSV+schema string.+ `with_compaction=False` keeps these tests on the legacy lossy+ path — same as the retention tests in `test_quality_retention.py`.+ """config = SmartCrusherConfig(enabled=True,min_tokens_to_crush=200,max_items_after_crush=20,)- return SmartCrusher(config=config)+ return SmartCrusher(config=config, with_compaction=False)def generate_log_entries(count: int, error_rate: float = 0.15) -> list[dict]: