Spaces:
Build error
Build error
Commit ·
e32d19d
1
Parent(s): f99f02a
Fix zstd streaming decompression, add zstandard dep; bump to 0.5.14
Browse filesUse stream_reader instead of decompress() for zstd request bodies.
Codex uses streaming zstd (no content size in frame header), which
causes decompress() to fail. stream_reader handles both cases.
Also added zstandard to the [proxy] optional dependencies.
- headroom/__init__.py +1 -1
- headroom/proxy/server.py +6 -2
- pyproject.toml +2 -1
headroom/__init__.py
CHANGED
|
@@ -153,7 +153,7 @@ from .transforms import (
|
|
| 153 |
TransformPipeline,
|
| 154 |
)
|
| 155 |
|
| 156 |
-
__version__ = "0.5.
|
| 157 |
|
| 158 |
__all__ = [
|
| 159 |
# Main client
|
|
|
|
| 153 |
TransformPipeline,
|
| 154 |
)
|
| 155 |
|
| 156 |
+
__version__ = "0.5.14"
|
| 157 |
|
| 158 |
__all__ = [
|
| 159 |
# Main client
|
headroom/proxy/server.py
CHANGED
|
@@ -558,9 +558,13 @@ async def _read_request_json(request: Request) -> dict[str, Any]:
|
|
| 558 |
import zstandard
|
| 559 |
|
| 560 |
dctx = zstandard.ZstdDecompressor()
|
| 561 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 562 |
except ImportError:
|
| 563 |
-
# Auto-detect: if bytes start with zstd magic (0x28 0xb5 0x2f 0xfd), fail clearly
|
| 564 |
raise ValueError(
|
| 565 |
"Request body is zstd-compressed but the 'zstandard' package is not installed. "
|
| 566 |
"Install it with: pip install zstandard"
|
|
|
|
| 558 |
import zstandard
|
| 559 |
|
| 560 |
dctx = zstandard.ZstdDecompressor()
|
| 561 |
+
# Use stream_reader for streaming zstd frames (no content size in header).
|
| 562 |
+
# Plain decompress() fails when the frame header omits the size, which
|
| 563 |
+
# is common with clients like OpenAI Codex.
|
| 564 |
+
reader = dctx.stream_reader(raw)
|
| 565 |
+
raw = reader.read()
|
| 566 |
+
reader.close()
|
| 567 |
except ImportError:
|
|
|
|
| 568 |
raise ValueError(
|
| 569 |
"Request body is zstd-compressed but the 'zstandard' package is not installed. "
|
| 570 |
"Install it with: pip install zstandard"
|
pyproject.toml
CHANGED
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
| 4 |
|
| 5 |
[project]
|
| 6 |
name = "headroom-ai"
|
| 7 |
-
version = "0.5.
|
| 8 |
description = "The Context Optimization Layer for LLM Applications - Cut costs by 50-90%"
|
| 9 |
readme = "README.md"
|
| 10 |
license = "Apache-2.0"
|
|
@@ -61,6 +61,7 @@ proxy = [
|
|
| 61 |
"openai>=2.14.0", # OpenAI API format support
|
| 62 |
"mcp>=1.0.0", # MCP server (headroom_compress, retrieve, stats)
|
| 63 |
"magika>=0.6.0", # ML content detection for ContentRouter
|
|
|
|
| 64 |
]
|
| 65 |
# AST-based code compression (tree-sitter)
|
| 66 |
code = [
|
|
|
|
| 4 |
|
| 5 |
[project]
|
| 6 |
name = "headroom-ai"
|
| 7 |
+
version = "0.5.14"
|
| 8 |
description = "The Context Optimization Layer for LLM Applications - Cut costs by 50-90%"
|
| 9 |
readme = "README.md"
|
| 10 |
license = "Apache-2.0"
|
|
|
|
| 61 |
"openai>=2.14.0", # OpenAI API format support
|
| 62 |
"mcp>=1.0.0", # MCP server (headroom_compress, retrieve, stats)
|
| 63 |
"magika>=0.6.0", # ML content detection for ContentRouter
|
| 64 |
+
"zstandard>=0.20.0", # Decompress zstd request bodies (Codex, etc.)
|
| 65 |
]
|
| 66 |
# AST-based code compression (tree-sitter)
|
| 67 |
code = [
|