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.

Merge pull request #302 from chopratejas/rust-stage-3d-compression-metrics

Tejas Chopra1ee1bb295b7c
diff --cc headroom/transforms/smart_crusher.py
index 66dddaac1,234fa4e06..b007e7841
--- a/headroom/transforms/smart_crusher.py
+++ b/headroom/transforms/smart_crusher.py
@@@ -167,16 -158,18 +168,22 @@@ class SmartCrusher(Transform)
cfg = config or SmartCrusherConfig()
self.config = cfg
self._with_compaction = with_compaction
+ # `observer`: see `headroom.transforms.observability`. The
+ # legacy proxy pipeline uses SmartCrusher.apply() directly
+ # (no ContentRouter); without an observer here, those
+ # compressions would be invisible to per-strategy metrics —
+ # exactly the silent-regression class we're guarding against.
+ self._observer = observer
# CCR config is preserved on `self` for callers that read it
- # back (`headroom.proxy.server` does), but the Rust port doesn't
- # exercise it: Stage 3c.1 keeps CCR marker injection disabled
- # because the Rust port has no compression store. When Stage
- # 3c.2 lands the CCR port, this wires through to Rust.
+ # back (`headroom.proxy.server` does). Storage-side semantics
+ # (CCR cache lookups) are honored via the Rust crusher's own
+ # CCR store. *Marker emission* is the gap: the Rust port emits
+ # `<<ccr:HASH N_rows_offloaded>>` markers unconditionally as
+ # part of `dropped_summary`, so `inject_retrieval_marker=False`
+ # has no effect on the prompt today. We log a WARNING (not
+ # debug) so it's visible. Suppression of marker emission needs
+ # a Rust-side gate; tracked in RUST_DEV.md.
if ccr_config is None:
self._ccr_config = CCRConfig(enabled=True, inject_retrieval_marker=False)
else: