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 zstd streaming decompression, add zstandard dep; bump to 0.5.14

chopratejas6212644587e0
diff --git a/headroom/__init__.py b/headroom/__init__.py
index cdec932b3..9017c7af4 100644
--- a/headroom/__init__.py
+++ b/headroom/__init__.py
@@ -153,7 +153,7 @@ from .transforms import (
TransformPipeline,
)
-__version__ = "0.5.13"
+__version__ = "0.5.14"
__all__ = [
# Main client
diff --git a/headroom/proxy/server.py b/headroom/proxy/server.py
index 4a514a57c..16e249b5f 100644
--- a/headroom/proxy/server.py
+++ b/headroom/proxy/server.py
@@ -558,9 +558,13 @@ async def _read_request_json(request: Request) -> dict[str, Any]:
import zstandard
dctx = zstandard.ZstdDecompressor()
- raw = dctx.decompress(raw)
+ # Use stream_reader for streaming zstd frames (no content size in header).
+ # Plain decompress() fails when the frame header omits the size, which
+ # is common with clients like OpenAI Codex.
+ reader = dctx.stream_reader(raw)
+ raw = reader.read()
+ reader.close()
except ImportError:
- # Auto-detect: if bytes start with zstd magic (0x28 0xb5 0x2f 0xfd), fail clearly
raise ValueError(
"Request body is zstd-compressed but the 'zstandard' package is not installed. "
"Install it with: pip install zstandard"
diff --git a/pyproject.toml b/pyproject.toml
index c0b2fff4c..b18a9bad9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
[project]
name = "headroom-ai"
-version = "0.5.13"
+version = "0.5.14"
description = "The Context Optimization Layer for LLM Applications - Cut costs by 50-90%"
readme = "README.md"
license = "Apache-2.0"
@@ -61,6 +61,7 @@ proxy = [
"openai>=2.14.0", # OpenAI API format support
"mcp>=1.0.0", # MCP server (headroom_compress, retrieve, stats)
"magika>=0.6.0", # ML content detection for ContentRouter
+ "zstandard>=0.20.0", # Decompress zstd request bodies (Codex, etc.)
]
# AST-based code compression (tree-sitter)
code = [