Skip to content

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.

fix: narrow compressed type for mypy 1.14 in ContentRouter.compress

chopratejas05fe6c010222
diff --git a/headroom/transforms/content_router.py b/headroom/transforms/content_router.py
index 07e0b880d..8c02c7753 100644
--- a/headroom/transforms/content_router.py
+++ b/headroom/transforms/content_router.py
@@ -1341,6 +1341,9 @@ class ContentRouter(Transform):
f"{decision_reason}_fallback_log_after_no_savings"
)
+ # Re-narrow for mypy: all reassignments above produce str, but
+ # mypy 1.14.x widens after nested try/except/else reassignments.
+ assert compressed is not None
if logger.isEnabledFor(logging.DEBUG):
_log_router_debug(
"content_router_strategy_result",