mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-08-27 14:17:10 -04:00
Fix zstd streaming decompression, add zstandard dep; bump to 0.5.14
Use 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.
This commit is contained in:
parent
8228f0edfb
commit
6212644587
3 changed files with 9 additions and 4 deletions
|
|
@ -153,7 +153,7 @@ from .transforms import (
|
|||
TransformPipeline,
|
||||
)
|
||||
|
||||
__version__ = "0.5.13"
|
||||
__version__ = "0.5.14"
|
||||
|
||||
__all__ = [
|
||||
# Main client
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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 = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue