#3609·headroom

[BUG] Embedded JSON compression can short-circuit parent HTML compression

Author: arx48Created Sep 16, 2026Updated Sep 16, 2026
Labelsbug

Description

The embedded JSON pre-pass can terminate routing too early when a larger structured document contains a small JSON fragment.

I observed this with HTML content that contains embedded JSON. The embedded JSON was successfully compressed, but the router returned immediately afterward, so the full document never reached the HTML-specific compressor.

Observed behavior

In one case:

  • The embedded JSON fragment was reduced from about 814 tokens to 277 tokens.
  • The overall document reduction was only around 2%.
  • When the embedded JSON path was disabled, the same content reached HTMLExtractor.
  • HTMLExtractor reduced the document from about 24,758 tokens to 1,102 tokens, roughly a 95.5% reduction.

So a small local optimization prevented a much larger document-level optimization.

Expected behavior

Embedded JSON compression should not automatically terminate processing of the entire parent document.

For content with a clear parent format such as HTML, I would expect one of the following behaviors:

  • Detect and preserve the parent format first.
  • Compress embedded JSON as a nested optimization, then continue processing the parent HTML.
  • Only allow embedded JSON compression to short-circuit routing when there is no stronger parent-level strategy available.

Environment

Headroom 0.37.0 Proxy mode Token optimization mode WSL / Linux

Source: headroomlabs-ai/headroom