Explore The mechanics, worked: seven scenarios step by step - compress, marker, retrieve - and the two flows that close the loop.
THE WORKED SCENARIOS // HOW IT ACTUALLY MOVES
Seven scenarios,
one lifecycle
A tool call's output is appended to the model's context, and the model reads every line of it. These are the scenarios where Aphrodite changes what arrives.
Not what the output looks like - what happens to it, step by step.
- 01 // RETRIEVE A marker travels from compression to byte-exact retrieval.
- 02 // PASS-THROUGH Essential tools refuse the machine.
- 03 // COMPOUND COMMANDS A compound command splits into segments.
- 04 // THRESHOLDS A threshold edit propagates through a running proxy.
- 05 // DIRECTIVES Directives assemble under a budget.
- 06 // RELAY A relay call fires a callback.
- 07 // STORAGE And the same payload crosses two listeners without changing shape.
ON THIS PAGE 9 SECTIONS
01 // RETRIEVE
Retrieve the original output
The lifecycle of one payload: the hook hashed it (BLAKE3), stored the bytes in the session store, and replaced the output with a {"<< marker plus a preview.
The transcript then carried the marker instead of the content - hash, type, size, ~15 tokens.
When the next action needs the substance, the agent calls aphrodite_retrieve with the hash - or pastes the marker body directly; every retrieval entry point accepts it, suffix or no suffix.
What comes back is the original content byte-for-byte, nested markers resolved recursively (docs/ccr/marker-format.md).
The caveat, printed on the tool's own contract: markers stay resolvable for the life of the session but do not survive a session restart - the dylib is loaded once per process, so a new session starts a fresh store (docs/tool-relay/tools.md:36-39).
The proxy's token listener backs its store with SQLite, which is the durability escape from that rule.
01 // THE COMMAND
APHRODITE_RETRIEVE(HASH) 02 // THE OUTPUT
03 // PREVIEW + MARKER
Original retained
- <<<CCR:hash|type|size>>>
- STANDARD - THE WIRE FORMAT
- [CCR:hash]
- BRACKET
- ⧗CCR:hash⧘
- UNICODE - U+2AF7 / U+2AF8
SRC: docs/tool-relay/tools.md:36-39 · docs/ccr/marker-format.md:76-86 · CHANGELOG.md:613-626 · README.md:298-299,506
02 // PASS-THROUGH
What stays raw, and why
Before any classification or storage, transform_tool_result runs its skip gates: a result is left untouched when it is empty; when the tool is in the essential set - skill_view, skills_list, skill_manage, memory, session_search, read_file, read_terminal; when it is one of Aphrodite's own tools or a headroom helper; or when it sits below the tool threshold (docs/plugin/hooks.md:76-83).
The logic is not protectionism - it is information theory per surface.
The essential tools return compact, self-describing metadata the agent needs raw: a skill's instructions, a memory entry, a file's content.
Compressing them would trade precision for nothing.
The self-tools are already the compressed form: their output is a marker or a catalog, and marking a marker is the preview-doubling bug in slow motion.
And the size gate is the quiet one - most tool output is simply small, and passes through without a store entry ever existing.
One subtlety: the hook tracks file references before the skip gates, so read_file and search_files results feed the recall catalog even when it never compresses them (docs/plugin/hooks.md:92-94).
01 // THE COMMAND
read_file 02 // THE OUTPUT
03 // PREVIEW + MARKER
Original retained
The gate order is fixed: the empty check, the essential set, the self-tools, then the size gate (docs/plugin/hooks.md:69-94).
The classifier demo in the workbench walks the same gates with live output.
SRC: docs/plugin/hooks.md:69-94,146-153 · docs/config/aphrodite-toml.md:121-131
03 // COMPOUND COMMANDS
One command, many markers
Chain-split is a Hermes plugin-side feature, not a proxy one: with it enabled, pre_tool_call rewrites a chained shell command by echoing segment markers, and transform_terminal_output splits the produced output into per-segment pieces - the hook compresses each segment into its own marker, so the model sees several compact previews instead of one large blob (docs/proxy/compression.md:366-379).
It is opt-in: chain_split = false by default, because invisible segment markers pollute redirected stdout.
The split floor and cap are chain_split_min_segments = 2 and chain_split_max_segments = 6.
The split is unconditional once marked - segment compression happens before the threshold gate, so marked output never leaks raw.
And it is careful: constructs that would corrupt control flow (heredocs, loops spanning segments) are left untouched.
The proxy never performs chain splitting - it only sees Chat Completions responses.
01 // THE COMMAND
cd project && cargo build --release && cargo test 2>&1 02 // THE OUTPUT
03 // PREVIEW + MARKER
Original retained
OFF BY DEFAULT · Without the split, the same compound command is one terminal blob with one marker - <<<CCR:e7c0f3a6...c1f4|terminal|1317>>>, whose size is the two segments summed plus the newline that joins them; the build preview and the test preview never separate.
Every size in this scenario measures the same thing: the UTF-8 bytes of the lines behind the marker, while the number inside a preview counts lines. That is why one segment reads 12L in its preview and 555 in its marker - two measurements of one segment, never two estimates of it.
The command itself is the case the split exists for: cd project && cargo build --release && cargo test 2>&1 - one call, two tools, redirected stdout.
Marked output is compressed before the threshold gate, so a split segment never leaks raw even when it is small enough to have passed through whole.
SRC: docs/proxy/compression.md:366-379 · docs/plugin/hooks.md:59-65,102-106 · README.md:411-413
04 // THRESHOLDS
Change compression thresholds without restarting
The four hot-reload thresholds are the only compression values the running proxy re-reads: tool_threshold_token, tool_threshold_cache, inline_threshold and code_multiplier.
Edit + save, or POST /reload - the new values apply immediately, with no restart (README.md:389-391).
Everything else about a proxy is fixed at startup.
One payload is the whole demonstration: the preview and the marker count the same bytes - the blob's own UTF-8 length, because [text:{lines}L {bytes}B | first line] is the plain-text preview shape (docs/classification/content-types.md:153). That is why this scenario reads 1000B in the preview beside this claim and 1000 in its marker, and why every clause below measures those same bytes.
Two coherent settings exist in the repo as configuration files and the comparison walks both: the shipped example (256 / 2048 / 1.0 / 1024) and the docs/examples values (512 / 4096 / 3.0 / 2048). The compiled default that each one overrides is in the disclosure beneath the table.
The arithmetic is the teaching - the same 1,000 bytes cross all four doors at both settings, and the comparison says which door changes its answer and which does not; neither column is rounded.
01 // THE COMMAND
POST /reload 02 // THE OUTPUT
03 // PREVIEW + MARKER
Original retained
SRC: README.md:389-407,584-588 · docs/architecture/07-config-resolution.md:66-71 · docs/config/aphrodite-toml.md:121-131,204 · aphrodite.toml.example:95-123 · docs/examples/README.md:21 · docs/classification/content-types.md:153
Swipe the table sideways: the docs column and the same-answer verdict are off-screen here.
| DECISION |
SHIPPED EXAMPLE
256 / 2048 / 1.0 / 1024 |
DOCS/EXAMPLES
512 / 4096 / 3.0 / 2048 | SAME ANSWER? |
|---|---|---|---|
| TOKEN PROXY 256 / 512 | MARKER 1000 > 256 - compressed, preview + marker | MARKER 1000 > 512 - compressed, preview + marker | SAME |
| CACHE PROXY 2048 / 4096 | RAW 1000 < 2048 - passes through untouched | RAW 1000 < 4096 - passes through untouched | SAME |
| AS SOURCE CODE 256 / 1536 | MARKER 256 x 1.0 = 256 headroom; 1000 > 256 | RAW 512 x 3.0 = 1536 headroom; 1000 < 1536 | DIFFERS |
| STORAGE CUTOFF 1024 / 2048 | INLINE had it compressed: 1000 < 1024 stays inline zlib | INLINE had it compressed: below 2048 stays inline zlib | SAME |
DETAIL Show thresholds behind these decisions
Three values are in play, and the comparison prints two of them rather than picking one and calling it the default: the shipped example (256 / 2048 / 1.0 / 1024), the docs/examples values the bench configs also ship (512 / 4096 / 3.0 / 2048), and the compiled defaults a bare binary runs with. An installation using the shipped example sees the first column, a tuned install sees the second, and a binary with no configuration file sees the third.
| KEY | SHIPPED | COMPILED DEFAULT | DOCS/EXAMPLES | WHAT IT GATES |
|---|---|---|---|---|
| tool_threshold_token | 256 | 1024 | 512 | TOKEN PROXY · tool results above 256 bytes compress docs: tool results above 512 bytes compress |
| tool_threshold_cache | 2048 | 8192 | 4096 | CACHE PROXY · tool results above 2048 bytes compress docs: tool results above 4096 bytes compress |
| inline_threshold | 1024 | 256 | 2048 | STORAGE CUTOFF · above this, store instead of inline zlib docs: above 2048, store instead of inline zlib |
| code_multiplier | 1.0 | 3.0 | 3.0 | CODE TIER · code_* types get base threshold x 1.0 - no headroom in the example docs: code_* types get base threshold x 3 |
The mechanics of the hot path: the config-file watcher reacts to Modify events on aphrodite.toml with a 500 ms debounce, reloads the file, and stores the four resolved thresholds into every live AppState's atomics - nothing else is updated live (docs/architecture/07-config-resolution.md:71).
The dylib session is a different story: it re-applies config fields on change only when auto_reload = true (README.md:390-391).
05 // DIRECTIVES
Fit agent guidance into a fixed budget
Short behavioral .md files, baked into the binary and materialized on plugin registration, injected verbatim every pre_llm_call - they teach retrieval vocabulary, never the compression mechanism.
The discovery order is strictly first-wins, never merged: APHRODITE_DIRECTIVES_DIR → ./directives/ → ~/.hermes/aphrodite/directives/ → binary-relative.
Any .md file in a discovered directory becomes a directive named after its stem - the built-ins are not special-cased (docs/plugin/directives.md:51-58).
The budget math: 2,000 characters per directive body, 4,000 characters across all active directives combined - and the whole per-turn injection (directives + nudges + recall catalog + retrieve hint) lives under one hard cap, flow_budget_chars, default 4,000 (shipped example: 2,600).
Sections drop from the bottom when over budget; directives and nudges never drop.
01 // THE COMMAND
aphrodite_directive("swap", "explore") 02 // THE OUTPUT
03 // PREVIEW + MARKER
Original retained
- focus
- one primary action per turn, marker-aware retrieval
- foresight
- prefetch what the next turn will need, never wait on I/O
- ccr-handling
- how to read the marker and when to retrieve vs. skip
- cleanup
- catalog sweep, summarize, verify nothing left unresolved
- explore
- broad context, aggressive prefetch, resolve what matters
- lazy
- only what this turn strictly requires; defer the rest
- lazy-eval
- markers accumulate across turns; you decide when to resolve
- 01 · FIRST-TURN ORIENTATION
- turn 0 only, from [prompts] session_inject
- 02 · DIRECTIVES
- never dropped
- 03 · NUDGES
- one-shots, at most two - never dropped
- 04 · BACKGROUND STATUS
- yields under pressure
- 05 · RECALL CATALOG
- the first section dropped under budget
THE PRIORITY LADDER · Under budget pressure the recall catalog goes first, then background status.
Directives and nudges are never dropped - nudges are capped at two one-shots, so the floor is always the directive block plus up to two nudges (docs/plugin/hooks.md:123-137).
SRC: docs/plugin/directives.md:34-97 · docs/plugin/hooks.md:114-137,146-153 · README.md:415-440 · docs/config/env-vars.md:78
06 // RELAY
Return tool results inline or by callback
POST /tool/relay runs the tool synchronously unless the request carries a callback_url - then the call becomes asynchronous: the proxy answers immediately with {"{success: true, async_call: true}"}, executes the tool, and POSTs the real result to the callback URL later (docs/tool-relay/callbacks.md:29-48).
The guardrails are strict.
The callback URL must be https-only - http, including loopback, and any other scheme are rejected with HTTP 400 before anything executes (SSRF protection).
The delivery is a 5-second, fire-and-forget POST: no auth header, no retries, the outcome untracked (only relay calls themselves are counted in /stats).
Only aphrodite_retrieve, aphrodite_compress and aphrodite_list are relayable; anything else is an error.
On graceful shutdown the task tracker waits for in-flight deliveries, so none are lost mid-flight.
01 // THE COMMAND
POST /tool/relay 02 // THE OUTPUT
03 // PREVIEW + MARKER
Original retained
THE RESULT ITSELF · is compact metadata (hash, type, size, marker) - so it stays raw through the hook pipeline.
Compressing an aphrodite_retrieve result would replace resolved content with another marker, which is why it is never absorbed.
SRC: docs/tool-relay/callbacks.md:27-111,139-144 · docs/plugin/hooks.md:76-83
07 // STORAGE
Compare plugin and proxy behaviour
A single binary can run two listeners with different roles - the cache proxy on :9797 (in-memory DashMap, 10,000 entries, 8192-byte threshold) and the token proxy on :9798 (SQLite at ccr.db, 1024-byte threshold, persistent, tool-relay-capable).
Each has its own AppState and CCR backend; both bind to loopback by default (docs/proxy/architecture.md:9-35).
The parallel that matters: the same payload crosses the plugin-hook lane (the hook intercepts it at the tool boundary, no API round-trip) and the proxy lane (the proxy compresses Chat Completions responses in flight) - and the marker it becomes is byte-identical across the two paths, as are the enriched previews (CHANGELOG.md:616-617).
The preview-doubling regression of v1.3.4 was caught precisely because the two paths were held to that standard.
01 // THE COMMAND
transform_tool_result 02 // THE OUTPUT
03 // PREVIEW + MARKER
Original retained
- CACHE :9797
- DASHMAP · 10,000 · 8192-BYTE THRESHOLD · TRANSIENT
- TOKEN :9798
- SQLITE · ccr.db · 1024-BYTE THRESHOLD · PERSISTENT
SRC: docs/proxy/architecture.md:9-35 · README.md:287-299 · CHANGELOG.md:616-617
08 // TURN CYCLE
IN FIRING ORDER
The turn cycle
Each scenario zooms into one mechanism.
This is the loop that holds them: the six hooks, in firing order, with what the agent sees and what the system does at each step.
Two columns answer together: the transcript the model reads, and the work that
produced it. Every step cites the hook section that owns it, so the diagram is a
route into
docs/plugin/hooks.md
rather than a summary of it.
Step 1 of 6: SESSION START.
SRC: docs/plugin/hooks.md:13-20 (the six-hook table) · each step cites its hook section
09 // RUNTIME HOME
ISSUE #40, AS A DECISION WALK
One runtime home
The history behind issue #40, as a decision walk: how the runtime home is resolved today, and why both halves of the plugin agree by construction.
Each step names the rule that decides, the mechanism that carries it, and the changelog entry the claim rests on - so a reader can check the last column instead of trusting the first.
Step 1 of 5: EXPLICIT OVERRIDE.
SRC: CHANGELOG.md:104-154 (v1.6.3) · CHANGELOG.md:39-67 (v1.6.5) · issue #40