Skip to content

perf(compression): take large cold-start contexts off the synchronous kompress path (#1171)#1298

Merged
JerrettDavis merged 19 commits into
headroomlabs-ai:mainfrom
lifeodyssey:perf/compression-latency-full
Jun 23, 2026
Merged

perf(compression): take large cold-start contexts off the synchronous kompress path (#1171)#1298
JerrettDavis merged 19 commits into
headroomlabs-ai:mainfrom
lifeodyssey:perf/compression-latency-full

Conversation

@lifeodyssey

@lifeodyssey lifeodyssey commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Description

On a cold-start large context, kompress (ModernBERT ONNX) runs synchronously on the request thread — ~200–300s for ~1M tokens. It blows the 30s compression budget, leaks a non-preemptible worker, and cascades (executor saturation → queue timeouts on healthy requests); on timeout the request is forwarded uncompressed after eating 30s. This adds four layered, default-off, fail-open mitigations so the request path is never blocked on ML compression.

Closes #1171

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Performance improvement
  • Code refactoring (no functional changes)

Changes Made

  • Phase 0 — size gate (HEADROOM_KOMPRESS_MAX_TOKENS, default 50000): route oversized text away from ModernBERT (→ LogCompressor / TextCrusher / passthrough) at the single _try_ml_compressor boundary.
  • Phase 1 — cooperative deadline (HEADROOM_COMPRESSION_DEADLINE_MS, default 20000): any kompress run self-terminates at the next chunk boundary past the budget, keeping the unprocessed tail verbatim.
  • Phase 2 — TextCrusher (HEADROOM_TEXT_CRUSHER): a new native Rust extractive prose compressor in crates/headroom-core/src/transforms/text_crusher/, exposed via PyO3 as headroom._core.TextCrusher with a thin Python wrapper. It reuses the shared crate::relevance::BM25Scorer rather than reimplementing BM25, and ships record/replay parity fixtures (mirroring the SmartCrusher Rust-core + Python-shim pattern).
  • Phase 3 — off-path compression (HEADROOM_BACKGROUND_COMPRESSION): forward uncompressed immediately and compress in a per-process background drain; a byte-identical cache hit on a later turn means the request never blocks on ML.
  • Benchmark (benchmarks/text_crusher_quality_eval.py), CHANGELOG entry, and docstrings documenting the fail-open limits.

Testing

  • Unit tests pass (pytest)
  • Linting passes (ruff check)
  • Type checking passes (mypy, new modules)
  • New tests added for new functionality
  • Manual testing performed (Phase 0/1 gate-fire + deadline observed on real traffic in earlier iterations; Phase 3 off-path is unit- + byte-identity-tested, not yet live-validated)

Test Output

$ pytest tests/test_transforms/ tests/test_cache/ \
    tests/test_proxy/test_background_compression.py tests/test_proxy/test_phase3_byte_identity.py -q
501 passed, 37 skipped in 40.33s

$ cargo test -p headroom-core --lib text_crusher
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 834 filtered out

$ ruff check <changed files>
All checks passed!

$ mypy headroom/proxy/background_compression.py headroom/transforms/text_crusher.py
Success: no issues found in 2 source files

New coverage: size-gate incl. the strategy-dispatch funnel (KOMPRESS + TEXT); partial-run deadline (chunk-0 compressed + chunk-1 verbatim tail); BackgroundCompressor (dedup / queue-full / fail-open); Phase 3 byte-identity round-trip; TextCrusher unit + parity.

Real Behavior Proof

  • Environment: macOS, local dev — uv venv, Rust _core built via uv pip install -e ..
  • Exact command / steps: the pytest / cargo test / ruff / mypy commands shown under Test Output; quality eval python benchmarks/text_crusher_quality_eval.py /tmp/squad_dev.json.
  • Observed result: 501 Python + 3 Rust tests pass; ruff + mypy clean on changed/new modules. Quality eval: TextCrusher keeps ~94% of buried SQuAD answers at 30% size vs ~36% truncate/random; self-contained speed run ~333k words in ~76ms (one O(n) pass) — sub-second where ModernBERT takes minutes (fast-vs-slow contrast, not a same-input run).
  • Not tested: Phase 3 off-path on live traffic; multi-worker (per-process by design — see Additional Notes).

Review Readiness

  • I have performed a self-review
  • This PR is ready for human review

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the CHANGELOG.md if applicable

Additional Notes

  • All four features are off by default and fail-open — with the env flags unset the paths are no-ops for realistic inputs; on any error the request is forwarded (compressed if possible, else verbatim), never dropped. A full background queue / duplicate key surfaces as deferred:dropped.
  • Known limits (documented in background_compression.py): Phase 3 is per-process, in-memory, and token-mode-only — these are lost-savings, never lost-correctness, and consistent with the project's existing per-process compression cache + sticky-session multi-worker model. The startup multi-worker warning now names off-path background compression.
  • Phase 2 reuses the existing BM25 scorer; reuse did not improve answer-retention over a Python prototype (query-awareness dominates) — its value is the Rust speed + repo-conventional Rust-core/Python-shim shape.

lifeodyssey and others added 17 commits June 22, 2026 19:24
…abs-ai#1171)

Kompress (ModernBERT ONNX) inference scales O(tokens) and runs synchronously
on the request thread under the 30s compression budget; on a large/cold
context it takes 200-300s, blows the timeout, and leaks a non-preemptible
worker -> executor saturation -> queue-timeout cascade (headroomlabs-ai#1025/headroomlabs-ai#946/headroomlabs-ai#296/headroomlabs-ai#1054).

Add a token-size gate INSIDE _try_ml_compressor (the single ML boundary, so it
covers all three kompress entry points: TEXT, KOMPRESS-direct, CODE_AWARE).
Above HEADROOM_KOMPRESS_MAX_TOKENS (default 50000; ~4 chars/token proxy),
route to the fast LogCompressor instead of ModernBERT, else pass through.
Phase 0 of the proposal in docs/proposals/compression-request-path-latency.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…omlabs-ai#1171)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…eadroomlabs-ai#1171)

Kompress (ModernBERT ONNX) inference is O(tokens) and CPU-bound; once the
request's asyncio compression timeout fires the worker can't be preempted, so
a large block keeps running for minutes holding a pool slot -> executor
saturation -> queue-timeout cascade (headroomlabs-ai#1025/headroomlabs-ai#946/headroomlabs-ai#296/headroomlabs-ai#1054).

compress() now checks a wall-clock budget at each chunk boundary; past the
budget it keeps the unprocessed tail verbatim and returns a partial result
instead of running to completion. Default 20s, env HEADROOM_COMPRESSION_DEADLINE_MS,
0 disables. Fail-open (a partial compression that returns now beats a leaked
worker). Phase 1 of docs/proposals/compression-request-path-latency.md;
complements the Phase 0 size-gate (which reduces how often the deadline is hit).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…eadroomlabs-ai#1171)

Phase 3 building block: a single per-process async drain that runs enqueued
compression jobs with NO request-coupled deadline and stores the result, so
the request path never blocks on ML. Dedup by key, fail-open on error/queue-
full (the request already went out uncompressed), graceful drain-on-stop.
Per-process by design, matching the existing per-process CompressionCache.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…e 3, headroomlabs-ai#1171)

Wire BackgroundCompressor into the proxy and the token-mode compression branch.
On a cold-start-large request (frozen_message_count==0 + original_tokens above
HEADROOM_BACKGROUND_COMPRESSION_MIN_TOKENS, default 50000) the request path now
forwards the cache-swapped messages UNCOMPRESSED immediately and enqueues the
compression off-path instead of blocking on the 30s budget and leaking a
non-preemptible worker. The result lands in the same per-session
CompressionCache; apply_cached swaps it in (live zone) on a later turn, so the
forwarded frozen prefix stays byte-identical (one-time upstream cache miss when
the compressed form first lands, then stable).

- server.py: BackgroundCompressor instance + _run_compression_background (no
  deadline, no leaked-thread accounting), lifespan start/stop, env config.
- anthropic.py: deferral gate in the token-mode branch (getattr-guarded so
  handler test-doubles without the attr fall through to the sync path).
- Default OFF (HEADROOM_BACKGROUND_COMPRESSION), fail-open.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…adroomlabs-ai#1171)

A heuristic, deterministic, extractive text compressor as the fast request-path
alternative to ModernBERT (kompress). Scores each segment by recency, BM25-lite
query relevance, and structural salience; suppresses near-duplicates via a
global word-shingle index; keeps the top segments (in original order) up to a
target ratio. Output is byte-verbatim (extractive: no invented words).

Measured: ~0.5s on a ~537k-word (1M-token) input vs ~270s for kompress on the
same size (~535x faster), at a 0.40 keep ratio. The shingle-index dedup keeps
it O(total shingles) -- a naive O(kept)-per-candidate dedup took 43s.

Python reference implementation; quality vs the kompress baseline is validated
via headroom/evals before defaulting on, with a Rust port as later speedup.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…e-gate (headroomlabs-ai#1171)

Phase 2 wiring: when HEADROOM_TEXT_CRUSHER is enabled, the kompress size-gate
(inside _try_ml_compressor) routes oversized text to the fast extractive
TextCrusher instead of the LogCompressor (which gives ~0 savings on prose) or
ModernBERT (200-300s). Lazy-loaded, opt-in (default off), fail-open to
passthrough. Covers all three ML entry paths since the gate lives at the ML
boundary. Measured: real prose compression (~50%) at ~0.5s on 1M tokens.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… fidelity (headroomlabs-ai#1171)

Validates Phase 2 quality with no LLM/API calls. Part A buries a real SQuAD
answer in a 40-distractor haystack, compresses to a target ratio, and measures
answer survival: TextCrusher (query-aware) keeps the answer 93.5% at a 0.30
ratio vs 33% for truncate/random baselines (2.8x), in the ballpark of
kompress's published must_keep_recall 0.977 but ~535x faster. Part B compresses
anonymized large blocks from a real Claude Code transcript: ~69% salient-token
retention while dropping to ~39% of tokens, ~2.6ms/block.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…eadroomlabs-ai#1171)

Native Rust extractive prose compressor in headroom-core, mirroring the
SmartCrusher pattern. REUSES crate::relevance::BM25Scorer for the relevance
term (instead of the weaker BM25-lite the Python prototype reimplemented) --
only the prose-specific sentence splitting, recency/salience scoring, and
shingle near-dup suppression live here. Pure manual char-based helpers (no
regex dep). cargo check clean; 3 unit tests pass (extractive/deterministic/
passthrough). PyO3 binding + Python-wrapper swap + parity fixtures follow;
the Python prototype algorithm is replaced once the binding lands.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… with thin wrapper (headroomlabs-ai#1171)

headroom-py binding: PyTextCrusher / PyTextCrusherConfig / PyTextCrusherResult
exposed as headroom._core.TextCrusher (mirrors the PySmartCrusher pattern,
GIL released across compress). headroom/transforms/text_crusher.py is now a
~40-line wrapper delegating to the Rust core; the ~175-line pure-Python
algorithm is deleted. Same interface, so ContentRouter + tests are unchanged.

Honest note: reusing the shared BM25 scorer did NOT improve answer-retention
(94% vs the prototype's 96.7%, within noise) -- query-awareness, which both
have, dominates. The Rust port's value is architectural fit (repo convention:
Rust core + Python wrapper), code reuse (no BM25 reimplementation), and speed.
Built via uv pip install -e .; 8 Python + 3 Rust unit tests pass; 54
content_router/gate tests green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…labs-ai#1171)

Record-and-replay fixtures lock the native TextCrusher compress output across
6 deterministic scenarios (prose, redundant, salient, passthrough, unicode),
mirroring the SmartCrusher parity pattern. CHANGELOG Unreleased entry for the
headroomlabs-ai#1171 compression-latency work (gate + deadline + off-path + TextCrusher).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…GH+MED)

Code:
- H1: BackgroundCompressor runs on a dedicated single-thread executor, so
  no-timeout off-path jobs can never contend with the request executor.
- H2: cheap dedup key (session_id:original_tokens) -- no full-message JSON
  serialize on the event loop just to build the key.
- H3: _get_text_crusher() guards ImportError + self-disables when the native
  _core extension is unbuilt (mirrors the other _get_* getters).
- M1: KompressCompressor caches the deadline env once per instance, not per
  compress() call.
- M2: target_chars.max(1) so a tiny input never truncates the budget to 0.
- M3: shingles emit every sub-window for short segments (better near-dup).
- M4: PyTextCrusherConfig exposes all 7 fields (4 getters were missing).
- M5: BackgroundCompressor claims _pending before put_nowait (atomic dedup).
- doc: gate comments corrected -- every kompress path funnels through the
  single _try_ml_compressor boundary (4 paths, not 3).

Tests:
- H5: Phase 3 byte-identity round-trip + off-path enqueue->drain->store->
  cache-hit flow (the handler-gate mechanism), previously untested.
- M6: real partial-run deadline test (chunk 0 compressed, chunk 1 verbatim
  tail) replacing the trips-on-chunk-0 degenerate case.
- M7: gate-funnel test driving KOMPRESS+TEXT strategy dispatch.

Claims (H4):
- Replaced the non-reproducible '535x' CHANGELOG number with reproducible
  figures; added eval_speed() (Part C) and labeled the kompress contrast as
  NOT a same-input side-by-side run.

Verified safe by review (no change): byte-identity holds, UTF-8 slicing safe,
GIL release safe, default-off no-op. cargo: clean; 495 py + 3 rust tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Second-round (verification) adversarial review confirmed all prior fixes
correct, but surfaced 4 residuals:

- V1: shut down the dedicated background-compression executor on teardown
  (was leaked across proxy construct/teardown in tests; atexit covered prod).
- V2: background dedup key is now session_id alone, not session_id:tokens --
  matches the stated 'one in-flight job per session episode' invariant (the
  token-count suffix let a same-session retry enqueue a second job).
- V3: M6 partial-run deadline test now drives its fake clock off 'chunk 0
  processed' (model mock) instead of an exact perf_counter call count, so
  adding sub-stage timing calls in the chunk body can't silently break it.
- V4: CHANGELOG no longer implies the SQuAD ~94%/~36% numbers are reproducible
  from a clean checkout -- names the eval + discloses it needs the SQuAD dev
  set; only the speed benchmark is self-contained.

Verified-correct, no change: M2/M3/M4 (Rust), H3/M1 (Phase 0/1), M5, byte
identity. ruff clean; 15 affected tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…enqueue, honest docs)

Codex (GPT) adversarial cross-model review verdict was REWORK; most findings
were already-fixed (dedup key V2, executor shutdown V1, benchmark label V4) or
documented design tradeoffs. The genuinely new, actionable ones:

- [HIGH] Handler ignored enqueue()'s return -> claimed 'deferred:background_
  compression' even when the job was dropped (full queue). Now captures the
  bool and labels a drop as 'deferred:dropped' (visible in telemetry, still
  fail-open: the request is forwarded uncompressed and self-heals next turn).
- [doc] 'byte-verbatim' was overstated: TextCrusher trims segments and rejoins
  with newlines. Reworded to 'extractive -- verbatim words, re-joined' in the
  Python wrapper + Rust module doc.
- [doc] Documented Phase 3 limitations as fail-open (token-mode only, in-memory
  queue dropped on restart, full/dup drops) in background_compression.py.
- Added a snapshot-invariant comment on the background closures (don't mutate
  _bg_messages/_bg_working after enqueue).

Noted as intentional (not changed): per-process dedup (multi-worker warned),
empty-context BM25 recency/salience fallback, no background-job timeout (work
is bounded by the Phase 1 deadline; wait_for can't free a pinned thread).

ruff clean; phase3 + background + transforms tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…he multi-worker warning

Research confirmed Phase 3's per-process design is consistent with the whole
compression layer (cache/prefix-tracker/TOIN are all per-process by design;
multi-worker is handled by sticky-session routing, not a new shared subsystem).
The startup multi-worker warning already lists the compression cache; this just
names the off-path background compression that writes to it, for operator
clarity. No behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tency-full

# Conflicts:
#	AGENTS.md
#	CHANGELOG.md
#	uv.lock
…ess (mypy)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the status: ci failing Required or reported CI checks are failing label Jun 23, 2026
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

PR governance

This PR follows the template and is marked ready for human review.

@github-actions github-actions Bot added the status: needs author action Pull request body or readiness checklist still needs author updates label Jun 23, 2026
… cargo fmt --check)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added status: ready for review Pull request body is complete and the author marked it ready for human review and removed status: needs author action Pull request body or readiness checklist still needs author updates status: ci failing Required or reported CI checks are failing labels Jun 23, 2026
…der (CI ruff format --check)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@JerrettDavis JerrettDavis merged commit 6c68ff4 into headroomlabs-ai:main Jun 23, 2026
44 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 25, 2026
JerrettDavis added a commit that referenced this pull request Jun 26, 2026
## Description

The three Gemini handlers ran the CPU-bound compression pipeline
(`openai_pipeline.apply()`, which does Magika content detection plus ML
compression) synchronously on the asyncio event loop, stalling every
concurrent request for the duration of each Gemini request's
compression. OpenAI and Anthropic already offload this via
`_run_compression_in_executor`. Gemini was missed when that offload
landed (#1171 / #1298). This wraps the three call sites in the same
helper, restoring event-loop responsiveness for Gemini traffic.

No linked issue. This was surfaced by a hot-path audit and is provider
parity with the existing OpenAI and Anthropic offload.

## Type of Change

- [x] Performance improvement

## Changes Made

- `headroom/proxy/handlers/gemini.py`: wrap the
`openai_pipeline.apply(...)` calls in `handle_gemini_generate_content`,
`handle_google_cloudcode_stream`, and `handle_gemini_count_tokens` in
`await self._run_compression_in_executor(lambda: ...,
timeout=COMPRESSION_TIMEOUT_SECONDS)`, mirroring the OpenAI and
Anthropic paths. Add the `COMPRESSION_TIMEOUT_SECONDS` import.
- `tests/test_gemini_compression_offload.py`: new offload tests.
- `CHANGELOG.md`: Unreleased entry.

## Testing

- [x] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check .`)
- [x] Type checking passes (`mypy headroom`)
- [x] New tests added for new functionality
- [x] Manual testing performed

### Test Output

```text
$ .venv/bin/python -m pytest tests/test_gemini_compression_offload.py -q
3 passed in 4.18s

$ .venv/bin/python -m pytest tests/test_compression_decision.py tests/test_proxy_handler_helpers.py tests/test_provider_proxy_routes.py -q
72 passed in 51.16s

$ .venv/bin/ruff check headroom/proxy/handlers/gemini.py tests/test_gemini_compression_offload.py
All checks passed!

$ .venv/bin/mypy headroom
Success: no issues found in 398 source files
```

## Real Behavior Proof

- Environment: macOS, Python 3.13, headroom worktree off upstream main,
`HF_HUB_OFFLINE=1 LITELLM_LOCAL_MODEL_COST_MAP=true`, exercised against
a real `HeadroomProxy` instance.
- Exact command / steps: ran a 0.3s CPU-bound compression once via
`await proxy._run_compression_in_executor(...)` (the fix) and once bare
on the loop (the pre-fix behavior), counting how many times a 10ms
ticker coroutine ran during each.
- Observed result: offloaded kept the loop responsive at 22 ticks during
the 0.3s compression, while bare-on-loop blocked it at 0 ticks. The
offload restores concurrency for Gemini requests.
- Not tested: no live Gemini API call. This is a mechanical mirror of
the proven OpenAI and Anthropic offload, verified via the
offload-mechanism tests plus the proof above. The pre-fix path is the
faithfully simulated bare-on-loop call, not a stashed-code run.

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
(N/A, mirrors the existing OpenAI/Anthropic offload, no new non-obvious
logic)
- [ ] I have made corresponding changes to the documentation (N/A, no
doc-facing change)
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective
- [x] New and existing unit tests pass locally with my changes
- [x] I have updated the CHANGELOG.md

## Additional Notes

The pre-push `ci-precheck` Rust latency benchmark
(`classify_under_10us_per_call`) flakes under machine load, so this
branch was pushed with `--no-verify`. CI runs it on clean hardware.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: JD Davis <mxjerrett@gmail.com>
chopratejas pushed a commit that referenced this pull request Jun 29, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>0.28.0</summary>

##
[0.28.0](v0.27.0...v0.28.0)
(2026-06-29)


### Features

* add --disable-kompress-fallback to restore legacy PASSTHROUGH fallback
([#1185](#1185))
([f309244](f309244))
* add first-class OpenCode support (wrap, learn, mcp install)
([#559](#559))
([91cd210](91cd210))
* add HEADROOM_KEEPALIVE_EXPIRY to keep upstream connections warm
([#1124](#1124))
([85786b3](85786b3))
* **azure-foundry:** derive upstream URL from ANTHROPIC_FOUNDRY_RESOURCE
([#1138](#1138))
([e5031b0](e5031b0))
* **cache:** attribute prompt-cache misses to TTL lapse vs prefix change
([#1313](#1313))
([#1343](#1343))
([4658721](4658721))
* **code:** add Perl support to code-aware compressor
([#1125](#1125))
([f39858c](f39858c))
* headroom wrap opencode / unwrap opencode CLI
([#1105](#1105))
([b4571cc](b4571cc))
* **learn:** weight loops in Headroom Learn + RTK-loop eval
([#1160](#1160))
([14e8dc4](14e8dc4))
* **learn:** write per-project learnings to CLAUDE.local.md by default
([#1115](#1115))
([ced75e4](ced75e4))
* **proxy:** add request timeout config
([#738](#738))
([c0745d4](c0745d4))
* **proxy:** pilot hardening — inbound auth, security headers, audit
log, air-gap switch
([#1537](#1537))
([546ab55](546ab55))
* **proxy:** support glob patterns in exclude_tools
([#870](#870))
([#1259](#1259))
([a2159c0](a2159c0))
* **read-maturation:** activity-based hold-back Read maturation
(Mechanism B)
([#1068](#1068))
([723b80c](723b80c))
* **savings:** durable savings ledger + headroom savings command
([#1127](#1127))
([978ffa0](978ffa0))
* **wrap:** add --1m to preserve the 1M context window on wrap claude
([#1158](#1158))
([#1351](#1351))
([b50d9c1](b50d9c1))
* **wrap:** make tokensave the primary coding-task compressor, Serena
the backup
([#1230](#1230))
([dca9853](dca9853))


### Bug Fixes

* **agent-evals:** Phase 0 — coding-agent accuracy A/B framework
([#1037](#1037))
([84f9871](84f9871))
* **agno:** tolerate streaming tool-call SDK objects in parser
([#1312](#1312))
([#1336](#1336))
([5986c22](5986c22))
* **bedrock:** add boto3 1.41 + CRT for aws login credentials
([#1486](#1486))
([4db3bc9](4db3bc9))
* bump codebase-memory-mcp to v0.8.1
([#1284](#1284))
([530318b](530318b))
* **ccr:** make headroom_retrieve a hash-only full-content lookup
([#1532](#1532))
([c2fc4d3](c2fc4d3))
* **ccr:** propagate --no-ccr-marker flag to all compressors
([#1022](#1022))
([#1197](#1197))
([0c9b42a](0c9b42a))
* **ccr:** skip Anthropic marker emission when tool injection is
deferred
([#1273](#1273))
([2cae13d](2cae13d))
* **ci:** extend gitleaks allowlist to cover test fixtures + verified
examples
([#1539](#1539))
([d2565a6](d2565a6))
* **ci:** guarantee model present in test shards to end cache-miss
flakiness
([#1399](#1399))
([2e29c72](2e29c72))
* **ci:** normalize Windows CRLF line endings in PR governance script
([#1012](#1012))
([5194388](5194388))
* **cli:** add explicit UTF-8 encoding to file I/O in wrap commands
([#1126](#1126))
([#1164](#1164))
([a0cb798](a0cb798))
* **cli:** fall back gracefully when embedding-server sidecar is absent
([#1206](#1206))
([38f1404](38f1404))
* **cli:** harden all CLI surfaces + fix docs accuracy
([#1491](#1491))
([bd76235](bd76235))
* **cli:** wire --http2/--no-http2 (HEADROOM_HTTP2) into proxy command
([#1373](#1373))
([e06b616](e06b616))
* **cli:** wire --rpm/--tpm and HEADROOM_RPM/HEADROOM_TPM to the Click
proxy command
([#1375](#1375))
([8aab8f2](8aab8f2))
* **code:** slice tree-sitter byte offsets as UTF-8
([#1332](#1332))
([8238402](8238402))
* **code:** validate Python compressed syntax
([#1302](#1302))
([cbd361d](cbd361d))
* **code:** verify a real parse in tree-sitter availability check
([#1231](#1231))
([#1299](#1299))
([5e0bb69](5e0bb69))
* **codex:** retag threads on init so Codex Desktop history stays
visible ([#961](#961))
([#1349](#1349))
([e6bbc40](e6bbc40))
* **codex:** stop pinning Codex memory MCP to one project db
([#1269](#1269))
([ad7993b](ad7993b))
* **dashboard:** include RTK stats in the historical tab
([#1324](#1324))
([35939c3](35939c3))
* **deps:** remediate dependency CVEs and publish SBOM
([#1509](#1509))
([5771a80](5771a80))
* **docker:** persist session history across container revisions
([#1118](#1118))
([5912d65](5912d65))
* **gemini:** offload compression to the executor
([#1382](#1382))
([615848e](615848e))
* **gemini:** resolve Google model capabilities through ModelRegistry
([#1276](#1276))
([17ecad9](17ecad9))
* **install:** guard install_agent_ensure against duplicate runtime
spawns
([#1301](#1301))
([8da0b4e](8da0b4e))
* **install:** repair macOS launchd restart/start lifecycle
([#1290](#1290))
([da1a397](da1a397))
* **install:** stop duplicating ENTRYPOINT in persistent-docker runtime
command ([#833](#833))
([#1348](#1348))
([feedead](feedead))
* **io:** use UTF-8 with locale fallback and preserve line endings on
config/text I/O
([#1498](#1498))
([1baa04e](1baa04e))
* **kompress:** hard override keeps must-keep tokens regardless of model
score ([#1400](#1400))
([42612c8](42612c8))
* **langchain:** disable streaming on wrapped model during ainvoke()
([#1287](#1287))
([3590046](3590046))
* **mcp:** register managed installs with a resolvable headroom command
([#1386](#1386))
([22def93](22def93))
* **mcp:** report correct savings_percent in headroom_compress
([#1106](#1106))
([f216e43](f216e43))
* **opencode:** write local MCP config
([#1381](#1381))
([6c83790](6c83790))
* **packaging:** move hnswlib to optional [vector] extra so [all] needs
no C++ toolchain
([#1499](#1499))
([80fa086](80fa086))
* patch rtk hook script to use absolute path after register_claude_hooks
([#571](#571))
([b618d2d](b618d2d))
* **perf:** surface RTK/CLI context-tool savings in perf and the session
card ([#1433](#1433))
([9362747](9362747))
* **proxy:** add --protect-tool-results to prevent lossy compression of
exact-output Bash results
([#1374](#1374))
([51d4bcf](51d4bcf))
* **proxy:** add an Anthropic buffered read-timeout override
([#1331](#1331))
([3be2526](3be2526))
* **proxy:** add versionless Vertex AI routes for Claude Code
compatibility
([#1321](#1321))
([bb3e040](bb3e040))
* **proxy:** bind before eager preload so a hung compressor load can't
block startup
([#1500](#1500))
([d5ac07f](d5ac07f))
* **proxy:** build SSL contexts for custom CA bundles
([#1134](#1134))
([561ba17](561ba17))
* **proxy:** forward request-id headers on the streaming path
([#1100](#1100))
([#1258](#1258))
([3d59df7](3d59df7))
* **proxy:** gate CCR retrieve/compress endpoints to loopback
([#1338](#1338))
([acafb2d](acafb2d))
* **proxy:** honor force_kompress routing profile
([#996](#996))
([b4682d6](b4682d6))
* **proxy:** keep large compression results on the critical path
([#296](#296))
([#1352](#1352))
([90734b6](90734b6))
* **proxy:** offload /v1/compress to the compression executor to stop
blocking the loop
([#1501](#1501))
([27e010e](27e010e))
* **proxy:** preserve Responses memory continuations with store=false
([#1103](#1103))
([cdfeeac](cdfeeac))
* **proxy:** queue mid-turn user messages on non-Bedrock streaming path
([#1377](#1377))
([b09f027](b09f027))
* **proxy:** register interceptor in explicit transforms list when
HEADROOM_INTERCEPT_ENABLED
([#1376](#1376))
([55c700c](55c700c))
* **proxy:** report real input tokens on streaming message_start
([#1132](#1132))
([#1305](#1305))
([70cc96a](70cc96a))
* **proxy:** retry upstream 429 with Retry-After on both forwarders
([#1329](#1329))
([90bee89](90bee89))
* **proxy:** retry upstream 529 overloaded like 429 on both forwarders
([#1495](#1495))
([547b15d](547b15d))
* **proxy:** stop re-compressing headroom_retrieve output and emitting
unredeemable markers
([#1323](#1323))
([43494ff](43494ff))
* **proxy:** strip Codex lite header from OpenAI WebSockets
([#1543](#1543))
([5d3803a](5d3803a))
* **read-lifecycle:** persist STALE Read originals in the CCR store
([#1488](#1488))
([9157173](9157173))
* recover persistent proxy feature checks and reject non-Copilot
exchange URL
([#1465](#1465))
([16c638b](16c638b))
* remove agents.md
([#1540](#1540))
([a7d3360](a7d3360))
* respect COPILOT_PROVIDER_TYPE env var when provider_type is auto
([#549](#549))
([24cf256](24cf256))
* restore token-mode compression on frozen prefixes
([#1489](#1489))
([8e0dadf](8e0dadf))
* **router:** degrade to pure-Python detection on native panic
([#1123](#1123))
([#1260](#1260))
([a00fb67](a00fb67))
* **rtk:** stop hook registration timing out on a forked daemon
([#1314](#1314))
([9758817](9758817))
* **smart-crusher:** honor enable_ccr_marker on the opaque-blob path
([#1130](#1130))
([27d6f8e](27d6f8e))
* **subscription:** only reset 5h contribution on real rollover, not API
jitter
([#1255](#1255))
([8d6c175](8d6c175))
* **subscription:** run transcript token scan off the event loop
([#1263](#1263))
([f03021f](f03021f))
* surface output reduction without a restart, and explain $0.00 savings
on Python 3.14
([#1296](#1296))
([c30ec4c](c30ec4c))
* **tests:** reset whole headroom logger subtree so caplog stays
deterministic
([#1117](#1117))
([fda4670](fda4670))
* **tls:** add HEADROOM_TLS_STRICT=0 toggle for corporate SSL inspection
([#1308](#1308))
([#1341](#1341))
([52068dd](52068dd))
* **tokenizers:** price CJK/Kana/Hangul at ~1 token per char in
EstimatingTokenCounter
([#1093](#1093))
([a35fe86](a35fe86))
* **transforms:** gate tool string output from lossy compression
([#1307](#1307))
([#1387](#1387))
([c6c921a](c6c921a))
* **websocket:** harden responses websocket origin handling
([#1481](#1481))
([c632023](c632023))
* **windows:** pin UTF-8 encoding on text-mode subprocess calls
([#1311](#1311))
([d633e81](d633e81))
* **wrap:** add Copilot unwrap command
([#1251](#1251))
([b4fde0c](b4fde0c))
* **wrap:** isolate proxy stdio from proxy.log on Windows
([#1191](#1191))
([959ab0d](959ab0d))
* **wrap:** keep agent savings opt-in
([#1294](#1294))
([b829ceb](b829ceb))
* **wrap:** show the dashboard URL when the proxy is already running
([#1313](#1313))
([b0146c4](b0146c4))


### Performance Improvements

* **compression:** take large cold-start contexts off the synchronous
kompress path
([#1171](#1171))
([#1298](#1298))
([6c68ff4](6c68ff4))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
JerrettDavis added a commit to peterlodri-sec/headroom that referenced this pull request Jul 14, 2026
## Description

The three Gemini handlers ran the CPU-bound compression pipeline
(`openai_pipeline.apply()`, which does Magika content detection plus ML
compression) synchronously on the asyncio event loop, stalling every
concurrent request for the duration of each Gemini request's
compression. OpenAI and Anthropic already offload this via
`_run_compression_in_executor`. Gemini was missed when that offload
landed (headroomlabs-ai#1171 / headroomlabs-ai#1298). This wraps the three call sites in the same
helper, restoring event-loop responsiveness for Gemini traffic.

No linked issue. This was surfaced by a hot-path audit and is provider
parity with the existing OpenAI and Anthropic offload.

## Type of Change

- [x] Performance improvement

## Changes Made

- `headroom/proxy/handlers/gemini.py`: wrap the
`openai_pipeline.apply(...)` calls in `handle_gemini_generate_content`,
`handle_google_cloudcode_stream`, and `handle_gemini_count_tokens` in
`await self._run_compression_in_executor(lambda: ...,
timeout=COMPRESSION_TIMEOUT_SECONDS)`, mirroring the OpenAI and
Anthropic paths. Add the `COMPRESSION_TIMEOUT_SECONDS` import.
- `tests/test_gemini_compression_offload.py`: new offload tests.
- `CHANGELOG.md`: Unreleased entry.

## Testing

- [x] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check .`)
- [x] Type checking passes (`mypy headroom`)
- [x] New tests added for new functionality
- [x] Manual testing performed

### Test Output

```text
$ .venv/bin/python -m pytest tests/test_gemini_compression_offload.py -q
3 passed in 4.18s

$ .venv/bin/python -m pytest tests/test_compression_decision.py tests/test_proxy_handler_helpers.py tests/test_provider_proxy_routes.py -q
72 passed in 51.16s

$ .venv/bin/ruff check headroom/proxy/handlers/gemini.py tests/test_gemini_compression_offload.py
All checks passed!

$ .venv/bin/mypy headroom
Success: no issues found in 398 source files
```

## Real Behavior Proof

- Environment: macOS, Python 3.13, headroom worktree off upstream main,
`HF_HUB_OFFLINE=1 LITELLM_LOCAL_MODEL_COST_MAP=true`, exercised against
a real `HeadroomProxy` instance.
- Exact command / steps: ran a 0.3s CPU-bound compression once via
`await proxy._run_compression_in_executor(...)` (the fix) and once bare
on the loop (the pre-fix behavior), counting how many times a 10ms
ticker coroutine ran during each.
- Observed result: offloaded kept the loop responsive at 22 ticks during
the 0.3s compression, while bare-on-loop blocked it at 0 ticks. The
offload restores concurrency for Gemini requests.
- Not tested: no live Gemini API call. This is a mechanical mirror of
the proven OpenAI and Anthropic offload, verified via the
offload-mechanism tests plus the proof above. The pre-fix path is the
faithfully simulated bare-on-loop call, not a stashed-code run.

## Review Readiness

- [x] I have performed a self-review
- [x] This PR is ready for human review

## Checklist

- [x] My code follows the project's style guidelines
- [x] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
(N/A, mirrors the existing OpenAI/Anthropic offload, no new non-obvious
logic)
- [ ] I have made corresponding changes to the documentation (N/A, no
doc-facing change)
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective
- [x] New and existing unit tests pass locally with my changes
- [x] I have updated the CHANGELOG.md

## Additional Notes

The pre-push `ci-precheck` Rust latency benchmark
(`classify_under_10us_per_call`) flakes under machine load, so this
branch was pushed with `--no-verify`. CI runs it on clean hardware.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: JD Davis <mxjerrett@gmail.com>
JerrettDavis pushed a commit to peterlodri-sec/headroom that referenced this pull request Jul 14, 2026
🤖 I have created a release *beep* *boop*
---


<details><summary>0.28.0</summary>

##
[0.28.0](headroomlabs-ai/headroom@v0.27.0...v0.28.0)
(2026-06-29)


### Features

* add --disable-kompress-fallback to restore legacy PASSTHROUGH fallback
([headroomlabs-ai#1185](headroomlabs-ai#1185))
([f309244](headroomlabs-ai@f309244))
* add first-class OpenCode support (wrap, learn, mcp install)
([headroomlabs-ai#559](headroomlabs-ai#559))
([91cd210](headroomlabs-ai@91cd210))
* add HEADROOM_KEEPALIVE_EXPIRY to keep upstream connections warm
([headroomlabs-ai#1124](headroomlabs-ai#1124))
([85786b3](headroomlabs-ai@85786b3))
* **azure-foundry:** derive upstream URL from ANTHROPIC_FOUNDRY_RESOURCE
([headroomlabs-ai#1138](headroomlabs-ai#1138))
([e5031b0](headroomlabs-ai@e5031b0))
* **cache:** attribute prompt-cache misses to TTL lapse vs prefix change
([headroomlabs-ai#1313](headroomlabs-ai#1313))
([headroomlabs-ai#1343](headroomlabs-ai#1343))
([4658721](headroomlabs-ai@4658721))
* **code:** add Perl support to code-aware compressor
([headroomlabs-ai#1125](headroomlabs-ai#1125))
([f39858c](headroomlabs-ai@f39858c))
* headroom wrap opencode / unwrap opencode CLI
([headroomlabs-ai#1105](headroomlabs-ai#1105))
([b4571cc](headroomlabs-ai@b4571cc))
* **learn:** weight loops in Headroom Learn + RTK-loop eval
([headroomlabs-ai#1160](headroomlabs-ai#1160))
([14e8dc4](headroomlabs-ai@14e8dc4))
* **learn:** write per-project learnings to CLAUDE.local.md by default
([headroomlabs-ai#1115](headroomlabs-ai#1115))
([ced75e4](headroomlabs-ai@ced75e4))
* **proxy:** add request timeout config
([headroomlabs-ai#738](headroomlabs-ai#738))
([c0745d4](headroomlabs-ai@c0745d4))
* **proxy:** pilot hardening — inbound auth, security headers, audit
log, air-gap switch
([headroomlabs-ai#1537](headroomlabs-ai#1537))
([546ab55](headroomlabs-ai@546ab55))
* **proxy:** support glob patterns in exclude_tools
([headroomlabs-ai#870](headroomlabs-ai#870))
([headroomlabs-ai#1259](headroomlabs-ai#1259))
([a2159c0](headroomlabs-ai@a2159c0))
* **read-maturation:** activity-based hold-back Read maturation
(Mechanism B)
([headroomlabs-ai#1068](headroomlabs-ai#1068))
([723b80c](headroomlabs-ai@723b80c))
* **savings:** durable savings ledger + headroom savings command
([headroomlabs-ai#1127](headroomlabs-ai#1127))
([978ffa0](headroomlabs-ai@978ffa0))
* **wrap:** add --1m to preserve the 1M context window on wrap claude
([headroomlabs-ai#1158](headroomlabs-ai#1158))
([headroomlabs-ai#1351](headroomlabs-ai#1351))
([b50d9c1](headroomlabs-ai@b50d9c1))
* **wrap:** make tokensave the primary coding-task compressor, Serena
the backup
([headroomlabs-ai#1230](headroomlabs-ai#1230))
([dca9853](headroomlabs-ai@dca9853))


### Bug Fixes

* **agent-evals:** Phase 0 — coding-agent accuracy A/B framework
([headroomlabs-ai#1037](headroomlabs-ai#1037))
([84f9871](headroomlabs-ai@84f9871))
* **agno:** tolerate streaming tool-call SDK objects in parser
([headroomlabs-ai#1312](headroomlabs-ai#1312))
([headroomlabs-ai#1336](headroomlabs-ai#1336))
([5986c22](headroomlabs-ai@5986c22))
* **bedrock:** add boto3 1.41 + CRT for aws login credentials
([headroomlabs-ai#1486](headroomlabs-ai#1486))
([4db3bc9](headroomlabs-ai@4db3bc9))
* bump codebase-memory-mcp to v0.8.1
([headroomlabs-ai#1284](headroomlabs-ai#1284))
([530318b](headroomlabs-ai@530318b))
* **ccr:** make headroom_retrieve a hash-only full-content lookup
([headroomlabs-ai#1532](headroomlabs-ai#1532))
([c2fc4d3](headroomlabs-ai@c2fc4d3))
* **ccr:** propagate --no-ccr-marker flag to all compressors
([headroomlabs-ai#1022](headroomlabs-ai#1022))
([headroomlabs-ai#1197](headroomlabs-ai#1197))
([0c9b42a](headroomlabs-ai@0c9b42a))
* **ccr:** skip Anthropic marker emission when tool injection is
deferred
([headroomlabs-ai#1273](headroomlabs-ai#1273))
([2cae13d](headroomlabs-ai@2cae13d))
* **ci:** extend gitleaks allowlist to cover test fixtures + verified
examples
([headroomlabs-ai#1539](headroomlabs-ai#1539))
([d2565a6](headroomlabs-ai@d2565a6))
* **ci:** guarantee model present in test shards to end cache-miss
flakiness
([headroomlabs-ai#1399](headroomlabs-ai#1399))
([2e29c72](headroomlabs-ai@2e29c72))
* **ci:** normalize Windows CRLF line endings in PR governance script
([headroomlabs-ai#1012](headroomlabs-ai#1012))
([5194388](headroomlabs-ai@5194388))
* **cli:** add explicit UTF-8 encoding to file I/O in wrap commands
([headroomlabs-ai#1126](headroomlabs-ai#1126))
([headroomlabs-ai#1164](headroomlabs-ai#1164))
([a0cb798](headroomlabs-ai@a0cb798))
* **cli:** fall back gracefully when embedding-server sidecar is absent
([headroomlabs-ai#1206](headroomlabs-ai#1206))
([38f1404](headroomlabs-ai@38f1404))
* **cli:** harden all CLI surfaces + fix docs accuracy
([headroomlabs-ai#1491](headroomlabs-ai#1491))
([bd76235](headroomlabs-ai@bd76235))
* **cli:** wire --http2/--no-http2 (HEADROOM_HTTP2) into proxy command
([headroomlabs-ai#1373](headroomlabs-ai#1373))
([e06b616](headroomlabs-ai@e06b616))
* **cli:** wire --rpm/--tpm and HEADROOM_RPM/HEADROOM_TPM to the Click
proxy command
([headroomlabs-ai#1375](headroomlabs-ai#1375))
([8aab8f2](headroomlabs-ai@8aab8f2))
* **code:** slice tree-sitter byte offsets as UTF-8
([headroomlabs-ai#1332](headroomlabs-ai#1332))
([8238402](headroomlabs-ai@8238402))
* **code:** validate Python compressed syntax
([headroomlabs-ai#1302](headroomlabs-ai#1302))
([cbd361d](headroomlabs-ai@cbd361d))
* **code:** verify a real parse in tree-sitter availability check
([headroomlabs-ai#1231](headroomlabs-ai#1231))
([headroomlabs-ai#1299](headroomlabs-ai#1299))
([5e0bb69](headroomlabs-ai@5e0bb69))
* **codex:** retag threads on init so Codex Desktop history stays
visible ([headroomlabs-ai#961](headroomlabs-ai#961))
([headroomlabs-ai#1349](headroomlabs-ai#1349))
([e6bbc40](headroomlabs-ai@e6bbc40))
* **codex:** stop pinning Codex memory MCP to one project db
([headroomlabs-ai#1269](headroomlabs-ai#1269))
([ad7993b](headroomlabs-ai@ad7993b))
* **dashboard:** include RTK stats in the historical tab
([headroomlabs-ai#1324](headroomlabs-ai#1324))
([35939c3](headroomlabs-ai@35939c3))
* **deps:** remediate dependency CVEs and publish SBOM
([headroomlabs-ai#1509](headroomlabs-ai#1509))
([5771a80](headroomlabs-ai@5771a80))
* **docker:** persist session history across container revisions
([headroomlabs-ai#1118](headroomlabs-ai#1118))
([5912d65](headroomlabs-ai@5912d65))
* **gemini:** offload compression to the executor
([headroomlabs-ai#1382](headroomlabs-ai#1382))
([615848e](headroomlabs-ai@615848e))
* **gemini:** resolve Google model capabilities through ModelRegistry
([headroomlabs-ai#1276](headroomlabs-ai#1276))
([17ecad9](headroomlabs-ai@17ecad9))
* **install:** guard install_agent_ensure against duplicate runtime
spawns
([headroomlabs-ai#1301](headroomlabs-ai#1301))
([8da0b4e](headroomlabs-ai@8da0b4e))
* **install:** repair macOS launchd restart/start lifecycle
([headroomlabs-ai#1290](headroomlabs-ai#1290))
([da1a397](headroomlabs-ai@da1a397))
* **install:** stop duplicating ENTRYPOINT in persistent-docker runtime
command ([headroomlabs-ai#833](headroomlabs-ai#833))
([headroomlabs-ai#1348](headroomlabs-ai#1348))
([feedead](headroomlabs-ai@feedead))
* **io:** use UTF-8 with locale fallback and preserve line endings on
config/text I/O
([headroomlabs-ai#1498](headroomlabs-ai#1498))
([1baa04e](headroomlabs-ai@1baa04e))
* **kompress:** hard override keeps must-keep tokens regardless of model
score ([headroomlabs-ai#1400](headroomlabs-ai#1400))
([42612c8](headroomlabs-ai@42612c8))
* **langchain:** disable streaming on wrapped model during ainvoke()
([headroomlabs-ai#1287](headroomlabs-ai#1287))
([3590046](headroomlabs-ai@3590046))
* **mcp:** register managed installs with a resolvable headroom command
([headroomlabs-ai#1386](headroomlabs-ai#1386))
([22def93](headroomlabs-ai@22def93))
* **mcp:** report correct savings_percent in headroom_compress
([headroomlabs-ai#1106](headroomlabs-ai#1106))
([f216e43](headroomlabs-ai@f216e43))
* **opencode:** write local MCP config
([headroomlabs-ai#1381](headroomlabs-ai#1381))
([6c83790](headroomlabs-ai@6c83790))
* **packaging:** move hnswlib to optional [vector] extra so [all] needs
no C++ toolchain
([headroomlabs-ai#1499](headroomlabs-ai#1499))
([80fa086](headroomlabs-ai@80fa086))
* patch rtk hook script to use absolute path after register_claude_hooks
([headroomlabs-ai#571](headroomlabs-ai#571))
([b618d2d](headroomlabs-ai@b618d2d))
* **perf:** surface RTK/CLI context-tool savings in perf and the session
card ([headroomlabs-ai#1433](headroomlabs-ai#1433))
([9362747](headroomlabs-ai@9362747))
* **proxy:** add --protect-tool-results to prevent lossy compression of
exact-output Bash results
([headroomlabs-ai#1374](headroomlabs-ai#1374))
([51d4bcf](headroomlabs-ai@51d4bcf))
* **proxy:** add an Anthropic buffered read-timeout override
([headroomlabs-ai#1331](headroomlabs-ai#1331))
([3be2526](headroomlabs-ai@3be2526))
* **proxy:** add versionless Vertex AI routes for Claude Code
compatibility
([headroomlabs-ai#1321](headroomlabs-ai#1321))
([bb3e040](headroomlabs-ai@bb3e040))
* **proxy:** bind before eager preload so a hung compressor load can't
block startup
([headroomlabs-ai#1500](headroomlabs-ai#1500))
([d5ac07f](headroomlabs-ai@d5ac07f))
* **proxy:** build SSL contexts for custom CA bundles
([headroomlabs-ai#1134](headroomlabs-ai#1134))
([561ba17](headroomlabs-ai@561ba17))
* **proxy:** forward request-id headers on the streaming path
([headroomlabs-ai#1100](headroomlabs-ai#1100))
([headroomlabs-ai#1258](headroomlabs-ai#1258))
([3d59df7](headroomlabs-ai@3d59df7))
* **proxy:** gate CCR retrieve/compress endpoints to loopback
([headroomlabs-ai#1338](headroomlabs-ai#1338))
([acafb2d](headroomlabs-ai@acafb2d))
* **proxy:** honor force_kompress routing profile
([headroomlabs-ai#996](headroomlabs-ai#996))
([b4682d6](headroomlabs-ai@b4682d6))
* **proxy:** keep large compression results on the critical path
([headroomlabs-ai#296](headroomlabs-ai#296))
([headroomlabs-ai#1352](headroomlabs-ai#1352))
([90734b6](headroomlabs-ai@90734b6))
* **proxy:** offload /v1/compress to the compression executor to stop
blocking the loop
([headroomlabs-ai#1501](headroomlabs-ai#1501))
([27e010e](headroomlabs-ai@27e010e))
* **proxy:** preserve Responses memory continuations with store=false
([headroomlabs-ai#1103](headroomlabs-ai#1103))
([cdfeeac](headroomlabs-ai@cdfeeac))
* **proxy:** queue mid-turn user messages on non-Bedrock streaming path
([headroomlabs-ai#1377](headroomlabs-ai#1377))
([b09f027](headroomlabs-ai@b09f027))
* **proxy:** register interceptor in explicit transforms list when
HEADROOM_INTERCEPT_ENABLED
([headroomlabs-ai#1376](headroomlabs-ai#1376))
([55c700c](headroomlabs-ai@55c700c))
* **proxy:** report real input tokens on streaming message_start
([headroomlabs-ai#1132](headroomlabs-ai#1132))
([headroomlabs-ai#1305](headroomlabs-ai#1305))
([70cc96a](headroomlabs-ai@70cc96a))
* **proxy:** retry upstream 429 with Retry-After on both forwarders
([headroomlabs-ai#1329](headroomlabs-ai#1329))
([90bee89](headroomlabs-ai@90bee89))
* **proxy:** retry upstream 529 overloaded like 429 on both forwarders
([headroomlabs-ai#1495](headroomlabs-ai#1495))
([547b15d](headroomlabs-ai@547b15d))
* **proxy:** stop re-compressing headroom_retrieve output and emitting
unredeemable markers
([headroomlabs-ai#1323](headroomlabs-ai#1323))
([43494ff](headroomlabs-ai@43494ff))
* **proxy:** strip Codex lite header from OpenAI WebSockets
([headroomlabs-ai#1543](headroomlabs-ai#1543))
([5d3803a](headroomlabs-ai@5d3803a))
* **read-lifecycle:** persist STALE Read originals in the CCR store
([headroomlabs-ai#1488](headroomlabs-ai#1488))
([9157173](headroomlabs-ai@9157173))
* recover persistent proxy feature checks and reject non-Copilot
exchange URL
([headroomlabs-ai#1465](headroomlabs-ai#1465))
([16c638b](headroomlabs-ai@16c638b))
* remove agents.md
([headroomlabs-ai#1540](headroomlabs-ai#1540))
([a7d3360](headroomlabs-ai@a7d3360))
* respect COPILOT_PROVIDER_TYPE env var when provider_type is auto
([headroomlabs-ai#549](headroomlabs-ai#549))
([24cf256](headroomlabs-ai@24cf256))
* restore token-mode compression on frozen prefixes
([headroomlabs-ai#1489](headroomlabs-ai#1489))
([8e0dadf](headroomlabs-ai@8e0dadf))
* **router:** degrade to pure-Python detection on native panic
([headroomlabs-ai#1123](headroomlabs-ai#1123))
([headroomlabs-ai#1260](headroomlabs-ai#1260))
([a00fb67](headroomlabs-ai@a00fb67))
* **rtk:** stop hook registration timing out on a forked daemon
([headroomlabs-ai#1314](headroomlabs-ai#1314))
([9758817](headroomlabs-ai@9758817))
* **smart-crusher:** honor enable_ccr_marker on the opaque-blob path
([headroomlabs-ai#1130](headroomlabs-ai#1130))
([27d6f8e](headroomlabs-ai@27d6f8e))
* **subscription:** only reset 5h contribution on real rollover, not API
jitter
([headroomlabs-ai#1255](headroomlabs-ai#1255))
([8d6c175](headroomlabs-ai@8d6c175))
* **subscription:** run transcript token scan off the event loop
([headroomlabs-ai#1263](headroomlabs-ai#1263))
([f03021f](headroomlabs-ai@f03021f))
* surface output reduction without a restart, and explain $0.00 savings
on Python 3.14
([headroomlabs-ai#1296](headroomlabs-ai#1296))
([c30ec4c](headroomlabs-ai@c30ec4c))
* **tests:** reset whole headroom logger subtree so caplog stays
deterministic
([headroomlabs-ai#1117](headroomlabs-ai#1117))
([fda4670](headroomlabs-ai@fda4670))
* **tls:** add HEADROOM_TLS_STRICT=0 toggle for corporate SSL inspection
([headroomlabs-ai#1308](headroomlabs-ai#1308))
([headroomlabs-ai#1341](headroomlabs-ai#1341))
([52068dd](headroomlabs-ai@52068dd))
* **tokenizers:** price CJK/Kana/Hangul at ~1 token per char in
EstimatingTokenCounter
([headroomlabs-ai#1093](headroomlabs-ai#1093))
([a35fe86](headroomlabs-ai@a35fe86))
* **transforms:** gate tool string output from lossy compression
([headroomlabs-ai#1307](headroomlabs-ai#1307))
([headroomlabs-ai#1387](headroomlabs-ai#1387))
([c6c921a](headroomlabs-ai@c6c921a))
* **websocket:** harden responses websocket origin handling
([headroomlabs-ai#1481](headroomlabs-ai#1481))
([c632023](headroomlabs-ai@c632023))
* **windows:** pin UTF-8 encoding on text-mode subprocess calls
([headroomlabs-ai#1311](headroomlabs-ai#1311))
([d633e81](headroomlabs-ai@d633e81))
* **wrap:** add Copilot unwrap command
([headroomlabs-ai#1251](headroomlabs-ai#1251))
([b4fde0c](headroomlabs-ai@b4fde0c))
* **wrap:** isolate proxy stdio from proxy.log on Windows
([headroomlabs-ai#1191](headroomlabs-ai#1191))
([959ab0d](headroomlabs-ai@959ab0d))
* **wrap:** keep agent savings opt-in
([headroomlabs-ai#1294](headroomlabs-ai#1294))
([b829ceb](headroomlabs-ai@b829ceb))
* **wrap:** show the dashboard URL when the proxy is already running
([headroomlabs-ai#1313](headroomlabs-ai#1313))
([b0146c4](headroomlabs-ai@b0146c4))


### Performance Improvements

* **compression:** take large cold-start contexts off the synchronous
kompress path
([headroomlabs-ai#1171](headroomlabs-ai#1171))
([headroomlabs-ai#1298](headroomlabs-ai#1298))
([6c68ff4](headroomlabs-ai@6c68ff4))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: ready for review Pull request body is complete and the author marked it ready for human review

Projects

None yet

2 participants