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
Route diffs to DiffCompressor via Magika label mapping
chopratejase1ad3e5db2a9
diff --git a/headroom/compression/detector.py b/headroom/compression/detector.pyindex 3a726a737..220d077e2 100644--- a/headroom/compression/detector.py+++ b/headroom/compression/detector.py@@ -32,6 +32,7 @@ class ContentType(Enum):JSON = "json"CODE = "code"LOG = "log"+ DIFF = "diff"MARKDOWN = "markdown"TEXT = "text"UNKNOWN = "unknown"@@ -309,6 +310,10 @@ class MagikaDetector:if label_lower in _MARKDOWN_LABELS:return ContentType.MARKDOWN, None+ # Diff format (Magika detects this with score=1.0)+ if label_lower == "diff":+ return ContentType.DIFF, None+# Text typesif label_lower in ("txt", "text", "ascii", "utf8", "empty"):return ContentType.TEXT, Nonediff --git a/headroom/transforms/content_router.py b/headroom/transforms/content_router.pyindex 4d13f3b6e..994fdf6fa 100644--- a/headroom/transforms/content_router.py+++ b/headroom/transforms/content_router.py@@ -74,6 +74,7 @@ def _detect_content(content: str) -> DetectionResult:"json": ContentType.JSON_ARRAY,"code": ContentType.SOURCE_CODE,"log": ContentType.BUILD_OUTPUT,+ "diff": ContentType.GIT_DIFF,"markdown": ContentType.PLAIN_TEXT,"text": ContentType.PLAIN_TEXT,"unknown": ContentType.PLAIN_TEXT,