Headroom findings applied to Yoshi

September 18, 2026 ยท View on GitHub

Inspected 2026-09-17 at commit b8b222f9403878efe08376eac71a626caf1920d6 in /tmp/yoshi-headroom.xsdVWy/headroom. Three read-only subagents independently inspected preservation, cache/recovery and benchmarks. No downloaded code was run. Benchmark runtime uses the already-installed Headroom 0.31.0, not downloaded main (0.37.0).

Applied

  • Exact duplicates before semantic pruning. headroom/transforms/cross_turn_dedup.py retains an original and references it from later copies. Yoshi compares the complete text, tool name and execution-input fingerprint, protects the original from Jev, and points later eligible duplicates to its tool ID. It now does this on the duplicate's first arrival: waiting for the semantic age window increased cache-write cost in the real diagnostic. Bash UI descriptions are excluded from execution identity. No similarity thresholds or partial deduplication.
  • Reversible structured representation. Inspired by lossless_compaction.py's inverse-transform postcondition, Yoshi independently implements canonical flat JSONL as columns, constants and row values. It accepts the transform only after exact byte reconstruction. Actual Claude runs then check exact event recall; software reversibility alone does not prove model comprehension.
  • Execution-error and multimodal protection. headroom/transforms/content_router.py and error_detection.py distinguish execution failures from ordinary successes. Yoshi never judges explicit errors, mixed image/document results or unpaired results; it also protects recognizable execution failures anywhere in the full text, outside the judge preview. Detection is conservative, not exhaustive.
  • Separate decision identity from prefix guarantees. headroom/cache/prefix_tracker.py guards positions and exact previously sent content. Yoshi persists content-bound, tenant/instruction-scoped decisions but explicitly does not claim provider-cache preservation. A changed user instruction reopens decisions; this can rebuild a cache prefix.
  • Measure behind the optimizer. In installed 0.31.0, CCR can generate additional provider calls and expose only the final response's usage to the client. The benchmark's common transparent relay sits after each optimizer and captures each actual upstream call.

Worth future experiments, not silently enabled

  • Checkpoint pruning versus rolling pruning: fewer prefix rebuilds at the cost of larger intervening prompts.
  • Original-output retrieval by session-scoped content ID, with a byte quota and expiry. Re-running a tool cannot guarantee recovering an old observation. Adding a recovery tool also changes tool schemas and requires stable schema bytes and a real agent-loop integration.
  • Extend reversible compaction to repeated unstructured log lines, with exact occurrence-count tasks. The delivered implementation handles canonical flat JSONL only.
  • Explicit read supersedence metadata (read_lifecycle.py). Do not treat every later Edit/Write as proof a read is disposable: the operation may fail or the task may need a before/after comparison.

Comparison caveats

  • Explicitly set --mode: installed 0.31.0 defaults to token; downloaded main defaults to cache.
  • --no-cache disables Headroom's semantic response cache, not Anthropic's prompt cache.
  • Default protected tool names include Read/Glob/Grep/Write/Edit. Bash remains compressible. Record which tools actually ran.
  • Some Headroom benchmarks use simulated perfect baselines, recorded token pricing or answer keywords. Their headline savings are not evidence for this experiment; run the baseline and use exact answers.
  • No Headroom implementation code is copied into Yoshi. The adaptations above are small independently written transformations inspired by the inspected designs.

Source: https://github.com/headroomlabs-ai/headroom/tree/b8b222f9403878efe08376eac71a626caf1920d6

Findings from live comparison diagnostics

  • Installed 0.31.0 cache/prefix_tracker.py:345-359 removes explicit message cache TTL and recreates bare ephemeral markers (5-minute default). Downloaded 0.37.0 preserves client ttl: 1h at :764-766,833 (#2375). The main benchmark normalizes all arms to 1 hour after optimization; pilot native costs are not called compression savings.
  • Installed proxy/handlers/anthropic.py:341-354,1048-1052,1197-1207 freezes the whole prefix in cache mode if the last message is not a user message. This Claude Code version ends requests with system-role budget reminders; logs explicitly say compression was skipped. Main 0.37.0 still has the same helper at :673-686.
  • Installed 0.31.0 hashes all system-role messages into its session ID (cache/prefix_tracker.py:765-779), so changing budget reminders also change its session identity. Main hashes only leading system messages (:1511-1536, #2085).
  • Token mode does attempt processing, but the tested blocks were rejected with ratio_too_high. The installed environment logs that Kompress is not installed. Therefore this is a comparison with that installed configuration, not a benchmark against every Headroom compression feature or latest Headroom. INFO logs do not establish the exact selected JSONL strategy.