CASE FILE // APHRODITE-CCR · SEP 2026 · MEASURED
THE CASE STUDY // WHY, NOT HOW

Why Aphrodite
is shaped this way

Not a tour of the code - an argument about the shape.

An agent's context is a budget, and every tool call spends it on raw output before the agent can decide whether any of it mattered.

Aphrodite's answer is structural: show the shape of the output, keep the substance on call, and make the agent - not the engine - the one who pays for detail.

SRC: README.md:694-740.

01 // THE CLAIMS // THREE LINES

The whole argument fits in three lines, and every section that follows is the evidence for one of them.

THE MARKER

IS THE CONTRACT

<<<CCR:hash|type|size>>> - the address, the kind, and the cost of going back, in one string both the agent and every retrieval entry point understand.

THE CLASSIFIER

IS THE GATE

Nothing moves until the type is named - because the type is what decides whether content earns visibility or a squeeze.

THE THRESHOLDS

ARE THE KNOBS

A handful of per-type multipliers and a fill threshold - each mapped to one question the agent asks, each tuned by what sessions prove.

That is the whole architecture: the agent keeps its budget for reasoning, and pays for detail only when detail is the answer.

ON THIS PAGE 8 SECTIONS

02 // THE PROBLEM // THE FLOOD

The flood is not the data's fault

Every file read, build, code search, or browser open floods the agent's context with raw output - compilation logs, accessibility trees, JSON blobs.

The structural failure is upstream: the agent spends its budget reading noise instead of reasoning, because raw output arrives before any decision - the context pays the full price for content the agent may never use.

Compression applied after the fact cannot refund a turn that already happened, so the intervention point has to be before the LLM sees anything.

That is the first design commitment: intercept at the tool boundary, not inside the prompt.

Aphrodite replaces the output with a compact, structured preview - ~15 tok of metadata instead of hundreds - and keeps the full content retrievable.

RAW STREAM // WHAT THE TERMINAL KEEPS cargo build --release 2>&1 9 LINES · 272 B
$ cargo build --release 2>&1
Compiling libc v0.2.168
Compiling tokio v1.47.1
Compiling serde v1.0.219
Compiling axum v0.8.4
Compiling aphrodite v1.6.6
... 136 more identical lines ...
warning: unused import: `HashMap`
Finished `release` [optimized] in 41.7s

The repeated compile steps fade out, the warnings that were already counted mute, and the one line that stopped the build stays at full strength. Every one of those lines is context the agent would have paid for.

PREVIEW // WHAT THE MODEL READS
ABSORBED · 56 B
ONE LINE, ONE MARKER
[build:1E 1W 142L | error[E0432]: unresolved import ...]
CUTOFF THE PREVIEW STOPS HERE · THE ORIGINAL IS STORED
Original retained
<<<CCR:0e3a5c9f...a1e|build|1420>>>

The same build on one line: the type, the counts, and the one error that mattered. The marker underneath is the address of the bytes that stayed behind - the agent pays for them only when this line fails to answer the question.

≈ 1,400 TOKENS · MOSTLY NOISE · ONE LINE MATTERED

03 // THE GATE // THE CLASSIFIER

The classifier is the gate

Why classify before compressing?

Because "compress everything equally" destroyed signal.

A compiler error and a verbose build log are both output - but one must stay visible and the other should never have been shown in full, and a single compression policy cannot serve both.

So the type-aware classifier runs first - 40-123 ns, first match wins - and each content type carries its own compression threshold tier.

The README's pipeline renders 20 types in its catalog, from build to text; the full classification registry backing it is 30 types (docs/classification/content-types.md).

When the classifier only reaches a generic bucket, a conservative semantic detector upgrades it to the high-signal shapes (git, gitlog, grep, ls, test); ordinary prose is never mis-tagged.

This is the "secret sauce" made plain: the classifier is the gate.

Nothing is compressed, stored, or marked until the gate has named it - and the name is what everything downstream keys on.

exemptevery blob is classified first16 pipeline types in the README framingthe semantic upgrade layer refinesgeneric text, terminal and log blobserror - x8code types - x3.0the code_multiplier defaultdiff, git, text - x2tool_output, json, rest - x1linter, build_output, log - BASEpinned, never halved, never tunedEMA auto-tune on top:ratio over 20 - x2.0ratio under 3 - x0.5budget header scales x0.5 to x1.0the full registry holds 30 typessee the content-type taxonomy
M2 // PREVIEW FLOW

The figure runs in one direction: every blob is classified first, then routed into one of five threshold groups:

  • error ×8
  • code ×3.0
  • tracked ×2
  • default ×1
  • and the noisy base group.

The noisy group is pinned - linter, build_output and log are never halved and never tuned.

On top of the tier sits the EMA auto-tune:

  • a type whose measured ratio stays above 20 doubles its patience
  • a type under 3 halves it
  • and the budget header scales the result between ×0.5 and ×1.0.

04 // THE CONTRACT // THE MARKER

The marker is the contract

Replacing output with a summary only works if the missing content stays reachable, and the bridge between the two is a single string:

<<<CCR:0e3a5c9f2b8d4e6a1c3f5b7d9e0a2c4b6d8f0a1e|build|1420>>>

Hash, type, size - in that order, on purpose.

01 HASH

The full 40-char BLAKE3 digest - the address of the stored original.

02 TYPE

Tells the agent what kind of thing it skipped.

03 SIZE

Tells it how much.

Three fields are all an agent needs to decide whether retrieval is worth it - which is exactly why the marker, not a tool call, is the contract: every retrieval entry point ( aphrodite_retrieve, /retrieve, resolve) accepts the marker body directly, suffix or no suffix.

The marker carries no content of its own - three fields and no payload - so it can be printed, copied and passed around without spending the budget it was minted to save.

The store behind it is deliberately boring: BLAKE3 → SQLite (persistent, the :9798 token listener) or in-memory DashMap (10K entries, the :9797 cache listener).

Storage is not the interesting problem: the agent's decision needs a stable address, and that is all the marker has to be.

05 // THE LOOP // FOUR LAYERS

Four layers, one decision

The pipeline is short on purpose: classify, preview, store, decide.

The whole compress step is sub-millisecond - end-to-end latency is 8-40 ms including the HTTP round-trip - because the design spends its complexity budget on the decision, not the transform.

LAYER // 01

40-123 ns
CLASSIFY
the gate: one type per invocation, first match wins

LAYER // 02

~15 tok
PREVIEW
the answer to 'do I care?' without the content

LAYER // 03

BLAKE3
STORE
SQLite / in-memory, the marker is the receipt

LAYER // 04

RETRIEVE?
DECIDE
the agent, not the engine, spends the budget

And the engine stays polite about it: compression is opt-in and non-destructive - everything the agent ever saw stays retrievable unchanged.

What the pre_llm_call hook adds each turn is an injection assembler, not a rewrite: directives are never dropped, nudges are capped at 2, background status and recall are the first things to yield, and the whole injection lives inside a 4,000-character budget.

Two modes cover every entry point - plugin hooks intercept tool results directly with no API round-trip, and the reverse proxy compresses Chat Completions responses for any OpenAI-compatible client.

No clever model, no lossy summarizer in the loop - just an honest receipt, a fast gate, and a set of knobs the evidence can turn.

The decision, in two branches

Every marker ends in the same question, and the agent answers it twice: the preview either carried enough, or it did not.

WHAT THE AGENT HOLDS

ONE PREVIEW + ONE MARKER · 1,420 B STORED

[build:1E 1W 142L | error[E0432]: unresolved import ...]

CUTOFF THE ORIGINAL IS STORED BELOW

<<<CCR:0e3a5c9f2b8d4e6a1c3f5b7d9e0a2c4b6d8f0a1e|build|1420>>>

Three fields and a preview line. Retrieval is a choice, not a step.

NOTHING IS RETRIEVED

The marker stayed a receipt. The agent reasoned from the type, the size and the one error the preview carried - and the store was never touched.

06 // THE KNOBS // THRESHOLDS

The thresholds are the knobs

A compression policy that cannot be tuned is a policy that will be fought.

Aphrodite's tunables are deliberately few and deliberately at the layer where they matter: the threshold multipliers per type (from aphrodite.toml's [compression]), the preview_max_chars preview budget, and the context engine's fill threshold ( engine_threshold_pct).

Few, because each knob maps to a question the agent actually asks: how patient should I be with this kind of output?

The adaptive layer answers it statistically - post_llm_call captures savings and updates EMA state per type - so the defaults move toward what the sessions themselves prove useful, and the config only has to set the priors.

The savings those priors produce across 200 real sessions - the ledger, the session-shape bands, the retrieval tax - are on the benchmarks page, which owns the study.

THRESHOLD TIERS
ERROR ×8
error
CODE ×1.0
code_rust · code_python · code_go · code_js · code
DIFF / TRACKED ×2
diff · git · text
DEFAULT ×1
tool_output · json · everything else
NOISY (BASE) ×1
linter · build_output · log
HIGHER MULTIPLIER = LONGER THE CONTENT STAYS VISIBLE BEFORE COMPRESSION
CODE ×1.0 IS THE SHIPPED DEFAULT ( CODE_MULTIPLIER) - SOURCE SITS AT THE BASE THRESHOLD UNTIL AN OPERATOR RAISES IT

SRC: README.md:305-371.

07 // THE EVIDENCE // WHAT ONE OUTPUT COSTS

What one output costs

Two measurements carry the argument: what each output class compressed to in the wild, and what the standard corpus paid per type.

The corpus ratios, the 610× ceiling, the median and the reproduce commands are on the benchmarks page.

Every bar is its ratio read as a width - 74× fills 74% of the scale - so the two columns compare magnitudes without normalising either one.

The pair carries the argument's sharpest claim: the ratio is a property of the content type, not of the session that produced it.

REAL-WORLD PER-OUTPUT COMPRESSION (ORIG → ~33 TOK MARKER) • ESTIMATED

TERMINAL

74 ×

TABLE

61 ×

SOURCE CODE

45 ×

LS

37 ×

DIFF

23 ×

BUILD

23 ×

SEARCH

20 ×

PER-TYPE COMPRESSION (STANDARD CORPUS) • MEASURED

GIT DIFF (42L) · ~350 tok → ~15 tok

23 ×

BUILD OUTPUT (142L) · ~1,400 tok → ~10 tok

140 ×

TERMINAL OUTPUT · ~200 tok → ~10 tok

20 ×

JSON BLOB (30 KEYS) · ~400 tok → ~10 tok

40 ×

BROWSER SNAPSHOT (342 EL) · ~5,000 tok → ~12 tok

416 ×

20/20 COMPRESSED · 20/20 RETRIEVE OK
RETRIEVAL TAX

Retrieval re-entry cost 2,275 calls and 2,011,583 tokens across the study - the price of going back for detail.

It is the reason the design pushes previews so hard: the tax only gets paid when the preview fails to answer the question, so the preview is engineered to answer most of them.

Read against the ledger, that is about 1.3% of the tokens the study saved: the whole cost of going back, paid only on the turns a preview did not answer. Paying the full output again instead would have cost roughly 78 times as much.

CONFIDENCE · The causal result - CCR removes context pressure for large repeated tool outputs, and tool-heavy usage benefits far more than chat - is high.

The exact percentage is a band: the marker's byte size is the only trace of the original content (the inline store is session-scoped), so savings were estimated with a calibrated chars/tok ratio; sensitivity across 3.0-4.5 chars/tok spans ~24-33%, centered ~27%.

And the study is an author-run reconstruction, not a randomised comparison: it establishes neither better task success nor universal cost savings. What it measures is how much context the markers replaced in these sessions, and what that reconstruction cost in tokens.

SAVINGS BY SESSION SHAPE

The same engine saves nothing in a chat and almost everything in a tool-heavy run, because the ratio tracks how much raw output the session produces at all.

CHAT-ONLY SESSIONS ~0%
LIGHT DEVELOPER SESSION ~5%
LONG TOOL-HEAVY SESSIONS 20-25%
PURE-TOOL WORKLOADS SIMULATED 76-82%

A pure-tool workload is the ceiling case and a chat-only session is the floor, which is why the study reports a median beside the mean. The fourth bar is a simulated loop, not a recorded session: it is marked as one because a stress test read as a fourth observation would be the page's own over-claim.

SAVINGS SCALE WITH TOOL-OUTPUT VOLUME AND SESSION LENGTH - THE SAME ENGINE, FOUR DIFFERENT PAYOFFS, ALL FROM THE SAME KNOBS.

SRC: README.md:694-740 (the per-output compression and the session-shape bands) · README.md:671-740 (the per-type table and the round trips).

08 // THE HISTORY SPINE // FIVE INCIDENTS

Five incidents that set the laws

Every rule in the engine was paid for once, and each arc runs the same three beats: the incident, the fix, and the mechanic that still stands today.

All of it is public record - the CHANGELOG entries and the release notes.

ARC 1 · v1.3.0 -> v1.3.2 · THE LOSSLESSNESS LAW

Hash the ORIGINAL, never the wrapper

01 The incident.

Compressing a Hermes wrapper stored the extracted content under hash(extracted) and discarded the original.

A failed command's exit_code and error fields were unrecoverable after compression, and caller JSON that merely matched a wrapper shape - e.g. {"content":"hi","id":42} - got permanently collapsed to one field.

02 The fix.

Both the hook and the tool paths now hash and store the ORIGINAL content always; the unwrapped view is used only for classification and preview.

03 Mechanics today.

Retrieval is byte-exact by construction - backends store and return content verbatim as UTF-8 strings, no zstd on the path - and a full-document retrieval (limit: 0) returns the exact original bytes, hashing back to the marker's own hash.

SRC: CHANGELOG.md:683-706 · docs/api/retrieve.md ("byte-exact by construction")

ARC 2 · v1.3.8 -> v1.3.9 · THE PUBLISHING INCIDENT

The tarball that compiled locally and failed everywhere else

01 The incident.

v1.3.8 published to crates.io but was uninstallable: Cargo.toml had exclude = [..., "*.md", ...], and cargo applies exclude at publish time - recursively.

The six builtin_directives/*.md files embedded via include_str! were stripped from the tarball, so the local checkout built fine and CI's Test job passed - but cargo install aphrodite failed at compile time.

02 The fix.

Drop the recursive *.md exclusion (and never combine include with exclude - cargo would ignore exclude and drop the targets), add a cargo package --list packaging guard to CI, and a durable in-crate regression test that fails when *.md returns to exclude.

03 Mechanics today.

crates.io versions are immutable - v1.3.8 stays broken forever, superseded as the working release; the packaging guard means this class of regression can never reach crates.io again.

SRC: CHANGELOG.md:408-450

ARC 3 · v1.6.3 · ONE RUNTIME HOME

One decision, made once, by both halves

01 The incident.

Issue #40: the plugin's Python shim resolved the runtime home from $HERMES_HOME while the Rust half resolved it from $HOME.

Whenever they diverged - the shipped Docker image, profile gateways - the shim looked for binaries in a directory that never existed, disabled the plugin, and orphaned the previous runtime home, config and provider API key included.

02 The fix.

The shim resolves the runtime home once ($APHRODITE_HOME override, then <hermes-home>/aphrodite, then ~/.hermes/aphrodite) and exports it to the Rust half through APHRODITE_HOME, so the dylib and the spawned proxy agree by construction.

Legacy installs are adopted with a one-line warning, never migrated.

03 Mechanics today.

Per-Hermes-home isolation extends to the whole stack, and the startup log names the decision: runtime home: <path> (decided by ...).

SRC: CHANGELOG.md:104-154

ARC 4 · v1.6.5 · THE CHECKSUM LAW

In-tree SHA256SUMS.txt is the only truth

01 The incident.

The download scripts used to fetch the release-hosted per-target checksums and had warn-and-skip paths - a missing checksum file or tool degraded to a warning instead of a refusal.

A plugin-hardening catalog review called it out.

02 The fix.

The pinned tree's SHA256SUMS.txt became the only checksum source of truth: a missing file, a BINARY_VERSION mismatch, a missing target block, or a missing asset entry is a hard refusal (exit 1), and a missing shasum/sha256sum tool is a hard refusal rather than a skipped check.

The legacy ~/.hermes/aphrodite home adoption in the runtime lookup is also gone.

03 Mechanics today.

Every release ships 12 artifacts - 4 targets x (binary, plugin dylib, SHA256SUMS) - and the dylib arm refuses installs when the in-tree checksums are missing.

SRC: CHANGELOG.md:39-67 · the Aphrodite/v1.6.5 release note

ARC 5 · v1.6.6 · THE PATH GUARDS

Some paths are never read

01 The incident.

Nothing stopped the prefetch path from reading the files most likely to contain secrets - environment files, auth tokens, SSH keys, or the Hermes home itself.

02 The fix.

aphrodite_prefetch refuses .env, auth.json, ~/.ssh, the Hermes home, and non-file paths outright, answering with ReadOutcome::Refused plus a refuse_reason instead of reading them.

03 Mechanics today.

Setup is hardened the same way: the Hermes-home plugin directory is report-only - no writes, no deletes - and the same release re-described the context engine as opt-in with a requires_hermes >= 0.20.2 floor.

SRC: CHANGELOG.md:3-37 · the Aphrodite/v1.6.6 release note