INDEX 09 / 14
The plugin
A tool call's output becomes part of the model's context, and the plugin is the only layer that sees that result before it becomes message history.
Aphrodite ships as a Hermes Agent plugin: a thin Python registration shim over a Rust dylib.
Six hooks, thirteen tools, and an opt-in context engine - all declared in plugin.yaml, all logic living in libaphrodite_hermes.dylib.
What follows is the v2.3.2 plugin spec.
A plugin is a promise about a binary. The manifest says which seams exist and which tools answer; validation exists to keep that promise and the running surface identical.
01 // PLUGIN.YAML // THE DECLARED SURFACE
What the manifest declares
The manifest is read before a line of Python loads. Hermes takes:
- the name it will list
- the spec version it will pin
- the six hook names it must find a registration for
- the thirteen tool schemas it will advertise to the model
- and the flag that says an engine is present.
Nothing in the file describes behavior. Every field is an identity, a requirement, or a promise about what the dylib will answer when it is asked - which is why a manifest that overstates the surface fails validation instead of failing at runtime.
The bar is full because the two sets are compared, not assumed: the manifest's provides_tools list and the schemas the release dylib reports are held to the same thirteen names.
The bar is empty on purpose. Nothing in the shim decides anything - a Python traceback means a load failure, never a compression bug.
ENGINE THRESHOLD SEMANTICS: -1 = ALWAYS COMPRESS · 0 = DISABLED · >0 = FILL PERCENT.
SKILLS ARE NOT SHIPPED WITH THE PLUGIN - THEY LIVE DEV-SIDE.
SRC: plugins/aphrodite/plugin.yaml (provides_hooks, provides_tools)
SRC: docs/plugin/context-engine.md:38-48
02 // ENGINE // OPT-IN, AND OFF BY DEFAULT
The engine is a flag, not a behavior
provides_context_engine: true does not turn anything on.
It tells Hermes that the dylib can answer the engine's questions - which file is being read, what the turn's markers were, how much context is left - so the host knows to ask.
The engine's own thresholds are the ones that decide whether a result is compressed at all.
The three threshold values are the whole tuning surface, and their polarity is the one thing readers get wrong: -1 compresses everything, 0 disables the engine, and a positive number is the fill percentage at which compression starts. A 0 that reads as "off by default" is the correct reading.
03 // ARCHITECTURE // CALL CHAIN
A thin shim, a Rust brain
Five layers, one contract between each pair. Read top to bottom, the list is the path a single tool result takes; read bottom to top, it is the path a retrieval takes when the model asks for the bytes back. The same engine answers as a proxy too, with no Hermes in the path.
Registration is driven by the dylib: the shim asks the dylib for its hook names and tool schemas and registers one callback per name.
It is the reason there is no hot-reload: the dylib is resolved once per process, so to pick up a new build you restart the Hermes session.
The proxy is the same engine one hop from the client: it needs no Hermes session, and responses compress over plain HTTP.
It needs its own credentials - APHRODITE_API_KEY, aphrodite setup, or api_key in aphrodite.toml - and Hermes' provider config is NOT reused. Without a key it refuses to start: there is no keyless mode.
The same resolve-once rule is why the plugin never half-loads. Either the dylib opens and every seam registers, or the import raises and nothing registers - there is no state in which three hooks fire and three do not.
What each layer does, and what it fails on
Hermes Agent
Owns the turn loop, the tool registry and the model call. It fires a hook because plugin.yaml promised one, and it reads the reply only as an object it can hand back.
A seam that was never registered is invisible here: the turn runs without it, so a plugin that failed to load looks exactly like a plugin with nothing to say.
__init__.py
Declares the ctypes signatures, asks the dylib for its hook names and tool schemas, and registers one callback per name. It holds no state between calls.
A dylib built against a different ABI raises at import, and the whole plugin is disabled - it does not degrade into a partial surface.
libaphrodite_hermes.dylib
The Hermes bridge: one JSON contract in, one JSON contract out, six hooks and thirteen tools with their schemas attached.
A reply the shim cannot parse is a hard error, never a guess - the bridge does not repair a malformed payload.
libaphrodite (core)
All the compression logic: classification, hashing, marker composition, preview extraction, directives, retrieval. Every number the engine reports is decided here.
A store that will not open degrades to the in-memory backend - the compression still happens, the persistence does not.
CCR store
SQLite at :9798, in-memory at :9797, or inline. It is the address space the markers point into, and the only layer that outlives the process.
A lost database loses markers, not the transcript: the previews still read, and a marker that no longer resolves returns an explicit miss.
One call, end to end
Two views of one call: what the agent sees, and what the process does. Following one call makes the split obvious - every intervention is invisible on the agent's side, and every rewrite is decided on the system's side.
Step 1 of 5: A HOOK FIRES.
The failure mode of the whole chain sits at the boundary, not in the middle:
- a hook that raises is logged and skipped
- a hook that returns nothing is a no-op
- and neither ever aborts the turn.
What a hook cannot do is pretend it ran.
04 // HOOKS // THE CHAIN
Six hooks, one turn
Every hook is a thin dispatch that forwards its arguments to the Rust dylib and hands the JSON reply back to Hermes.
It is the reason the shim registers one callback per name: on plugin load it asks the dylib for its hook names, and the six hooks are always registered together.
The turn, in order
The loop closes on itself, so the state a turn leaves behind is the state the next turn reads. That is why the reset seam exists: a new session starts from a clean baseline instead of inheriting the previous session's counters and markers.
The six, one card each
on_session_start
Resets every piece of per-session state to a clean baseline: turn counter, conversation index, recent markers, referenced files, tool-event telemetry, ephemeral directives.
Injects nothing - the one-shot first-turn orientation renders later, on the first pre_llm_call.
Fails on: a resumed session that skipped the reset carries the previous session's counters into the new one, and the turn-0 orientation never renders because the counter is not zero.
transform_tool_result
After every tool call: record telemetry, run the skip gates, classify the content type, hash (BLAKE3), store, and replace the output with <<<CCR:hash|type|size>>> plus a compact preview.
The hook tracks file references before the gates, so aphrodite_files sees every read even when nothing was compressed.
Fails on: a store that cannot write. The gate still passes, the marker still renders, and the bytes it addresses are gone - which is why the preview is written to answer the common question without the retrieve.
pre_llm_call
Runs the poll-worker checkpoint, then the context assembler: first-turn orientation (turn 0 only), [directives:] (never dropped), [nudge:] one-shots at most two (never dropped), background-task status, and the [recall] catalog - the first section dropped under pressure.
One hard budget: 4,000 chars.
Fails on: a budget with no room left. Directives and nudges are never dropped, so the sections that lose are the recall catalog first and the background status after it - the model is told less, never told wrong.
transform_terminal_output
Same pipeline for shell stdout/stderr.
The hook records non-zero exit codes as failures for the error-loop detector; chain-split segments compress unconditionally, before the threshold gate, so marked output never leaks raw; everything else passes the 1,024-char gate first.
Fails on: interleaved stdout and stderr. The stream is compressed as one buffer, so the ordering the terminal showed is the ordering the marker keeps - and a reader who needs the two separated must retrieve.
post_llm_call
Archives the last marker of the turn into the conversation index (so aphrodite_diff can report per-turn compressions), advances the turn counter, purges expired nudges after the counter advances - a one-shot nudge renders exactly once - and expires stale poll-worker tasks.
Fails on: a turn that never completes. No post-turn archive means no per-turn diff entry for it, and the nudge that should have expired waits for the next completed turn.
pre_tool_call
Two interventions before a tool executes.
Auto-backgrounding: the hook rewrites long-running terminal/process calls to run in the background (poll worker, default on).
Chain splitting (opt-in): the hook splits chained commands with invisible segment markers so each segment compresses into its own CCR marker.
Otherwise the call passes through unchanged.
Fails on: a rewritten call the agent never asked for still reads as a foreground result - the poll worker owns the status, and a stopped poll worker leaves the background job running with no reader.
What never gets compressed
A result is left untouched when it is empty, below threshold, or from the essential set - tools the agent needs raw:
Aphrodite also skips its own tools and headroom helpers - compressing aphrodite_retrieve would just replace resolved content with another marker.
The gate is the reason retrieval stays cheap: a marker the model resolves comes back whole, because nothing downstream of the gate rewrites it a second time.
The numbers that decide
| HOOK | SETTING | DEFAULT | BYPASS |
|---|---|---|---|
| transform_tool_result | tool_threshold_token | 4,096 | empty · essential tools · self tools · 0 = always compress |
| transform_terminal_output | terminal_threshold | 1,024 | empty · below threshold · 0 = always compress |
| pre_llm_call | flow budget_chars | 4,000 | recall catalog drops first; directives and nudges never drop |
| pre_tool_call (chain split) | chain_split_min_segments | - | feature off by default (chain_split = false) |
PRECEDENCE: ENVIRONMENT > TOML > DEFAULT (APHRODITE_TOOL_THRESHOLD_TOKEN · APHRODITE_TERMINAL_THRESHOLD · APHRODITE_FLOW_BUDGET_CHARS · APHRODITE_CHAIN_SPLIT).
The precedence matters at the edges: a value in the environment wins over the same key in aphrodite.toml, and the compiled default is only reached when neither exists. Every knob is listed on CONFIG .
SRC: docs/architecture/04-hook-ffi.md
SRC: docs/plugin/hooks.md; plugins/aphrodite/plugin.yaml (provides_hooks)
05 // DOWNLOAD // EXPLICIT STEPS ONLY
register() never downloads
The split is deliberate: loading a plugin is a read, and fetching a binary is a write. Keeping them apart means an agent that starts in a clean environment never silently pulls an executable over the network - the fetch is a step a person runs, with a verdict attached to it.
Binaries are never shipped in the repository.
Fetching them is an explicit setup step you run yourself - and the verification is mandatory, not best-effort:
- SHA-256 against the in-tree checksum list -
SHA256SUMS.txt, generated by CI into the tree; a mismatch is refused outright. - Magic-byte validation- the downloaded file must be a real ELF / Mach-O / PE image, or it is rejected.
- Backup + restore - an existing install is backed up and restored if any step fails. No release-hosted fallback.
- A missing binary disables, not breaks - the plugin logs the setup command and stays disabled until the binaries are present.
The four checks are ordered by cost, not by importance:
- the checksum is one hash
- the magic bytes are four
- the backup is a rename
- and the last one is not a check at all - it is what the plugin does when every check before it has already failed.
$ git clone https://github.com/PlayForm/Aphrodite-Hermes.git
$ cd Aphrodite-Hermes
$ ln -s "$(pwd)" ~/.hermes/plugins/aphrodite
$ bash download.sh // or: pwsh ./download.ps1
$ cd ..
$ hermes plugins enable aphrodite
$ hermesThe copy payload is 7 lines: clone, link, fetch, enable, start. The ln -s line is the one that makes the repo the plugin Hermes sees - the install directory is a symlink, not a copy.
ALSO ON THE STORE: the plugin is in the Hermes plugin catalog - the reviewed, pinned alternative to the manual clone.
hermes plugins install aphrodite checks out the catalog entry's exact commit, then bash download.sh from ~/.hermes/plugins/aphrodite still fetches the binaries (never aphrodite setup against the catalog-managed directory).
The full flow is on SETUP ; the mechanics are in the Hermes plugin guide .
The proxy needs its own key
LLM API KEY REQUIRED: the proxy is an OpenAI-compatible forwarder and needs its own credentials - APHRODITE_API_KEY, aphrodite setup, or api_key in ~/.hermes/aphrodite/aphrodite.toml.
Hermes' provider config is NOT reused, and there is no keyless mode: without a key the proxy refuses to start.
That refusal is the point. A forwarder that started without a key would accept a request, hold it, and fail it somewhere downstream - so the proxy checks first and exits with the missing variable named.
What happens without a config file
A MISSING CONFIG IS REPORTED, NOT INFERRED: when aphrodite.toml is absent the plugin says so, and the binary falls back to a single token-mode listener on the first port - the second proxy never binds, and every [compression] knob, the store retention caps included, is simply absent.
It is the reason the install runs aphrodite setup: the config file is written before the binary is ever started, so the fallback never becomes the everyday state.
The fallback is a floor, not a mode: one listener, token compression, no retention promise. It exists so a fresh checkout can answer a request before anyone has written a config, and it is reported every time it is in effect.
SRC: plugins/aphrodite/download.sh · SHA256SUMS.txt (generated by CI)
SRC: docs/guides/hermes-integration.md:115-141
06 // FILESYSTEM // CANONICAL LAYOUT
What changes after install
Two directories, two owners. Hermes owns the plugin directory and the plugin owns everything under the runtime home - the arrow annotations are the whole map of who writes what.
~/.hermes/plugins/aphrodite/
The catalog checkout. The plugin never creates, converts or modifies it, and the self-heal below stops at this boundary.
~/.hermes/aphrodite/
The runtime home: binaries, config, directives, the CCR store and the proxy logs.
The only two files that execute. Both arrive through download.sh and both are verified before they land; a failed fetch restores the pair that was already there.
The seven built-ins, materialized on first start so an edited directive is never silently overwritten by an upgrade. A deleted one comes back; a changed one stays changed.
The address space the markers point into. Delete it and the markers stop resolving - the previews in the transcript still read, which is why the store can be dropped without losing the conversation.
The self-heal, and where it stops
The runtime home self-heals toward layout_schema.json at startup: the self-heal moves misplaced config and binaries to their canonical paths and quarantines stale plugin-source copies.
It is the reason the self-healing stops at the Hermes-owned boundary: the ~/.hermes/plugins/aphrodite install dir is Hermes' territory, and the plugin never creates, converts, or modifies it.
The schema is the authority, not the directory listing: a file is misplaced when it is not where the schema says, and the repair is a move - never a copy, never a rewrite. Anything it cannot place it quarantines instead of deleting, so a stale copy is set aside with its bytes intact and the next start does not trip over it again.
SRC: plugins/aphrodite/layout_schema.json
07 // EVOLUTION // HOW THE SURFACE GREW
The six hooks, the version pairing, and the 14-to-13 correction
Three things grew at once:
- the seams
- the pairing rule that keeps a plugin pointing at a binary that exists
- and the discipline that keeps the declared tool count honest.
Read together they explain why the plugin can be installed from a tag and verified against a checksum list.
Six lanes, one trigger each
on_session_start
resets all per-session state to a clean baseline - injects nothing
pre_tool_call
auto-backgrounds long-running calls; splits chained commands
transform_tool_result
compresses large tool results into CCR markers
transform_terminal_output
compresses large terminal output into CCR markers
pre_llm_call
injects directives, nudges, and the recall catalog
post_llm_call
archives the turn, advances the counter, expires stale state
SRC: docs/plugin/hooks.md:13-20 - every hook is a thin dispatch that forwards to the Rust dylib; the dylib holds all the behavior.
Today's pairing: binary 1.8.1, plugin 2.3.2.
Every release moves both: " Binary 1.7.0 → 1.8.0, plugin 2.3.0 → 2.3.1"
BINARY_VERSION is pinned to a binary release tag the plugin can download.
Since the first plugin-first release (v1.4.6), the plugin is tagged before the parent, so the pinned version points at assets that already exist.
The plugin warns before download.sh when the pinned BINARY_VERSION points at a release with no assets - and since v1.6.5, a checksum mismatch is a hard refusal, not a warning.
The order is the mechanic. Tagging the plugin first means the pinned version can only ever point backwards, at a release whose assets are already uploaded and hashed - so the download has something to verify against before anyone asks for it.
SRC: CHANGELOG.md v1.4.6/v1.4.4/v1.6.5/v1.6.6 entries · the Aphrodite/v1.4.6 release note ("released plugin-first ... points at assets that already exist")
v1.6.5 corrected the manifest: "14 tools" → "13 tools" - the release dylib registers exactly the 13 declared tools.
The 14th, aphrodite_debug , is debug_assertions -gated out of release builds, matching what hermes plugins validate enforces.
Earlier, v1.6.1 had already removed it from provides_tools, closing the catalog-review mismatch on the pinned tree - and v1.4.6 had done the same for aphrodite_navigate , the navigation tool whose feature was unbuildable.
The declared surface and the running surface are kept identical on purpose.
The count is not cosmetic: the validator compares the manifest's tool list against the schemas the dylib reports, so a release that advertises fourteen while registering thirteen fails that comparison before a user ever runs it. A debug-only tool is therefore a build artifact, not a declared surface - and the manifest says so.
SRC: CHANGELOG.md:61-64 (v1.6.5) · CHANGELOG.md:166-173 (v1.6.1) · v1.4.6 release note
SRC: CHANGELOG.md v1.6.5 · CHANGELOG.md v1.6.1 · the Aphrodite/v1.4.6 release note
SRC: plugins/aphrodite/plugin.yaml (provides_tools)