AphroditeβπβHermes Plugin
[!NOTE]
CCR compression plugin for Hermes Agent - thin Python loader + Rust dylib.
Sub-ms tool output compression, multi-type classifier, 13 tools, 6 hooks,
default-on context engine, TOML-driven templates, auto-expand, live
containers, prompt knobs, recursion/body caps, optional Rhai scripting.
Skills ship dev-side, not with the plugin.
Aphrodite intercepts tool output before it reaches the LLM and replaces it with
compact, structured previews. The agent sees 15 tokens of metadata instead of
500 tokens of raw text - and retrieves the full content only when it actually
needs it. All compression logic runs in the Rust dylib.
Priced retrieval: every <<<CCR:hash|type|size>>> marker's size is its
retrieval cost - resolving it re-adds that many bytes to context. Previews
answer the structural questions (succeeded? which files? how many? what
shape?) for free; deferral is safe - markers persist and stay retrievable;
batch the retrievals you actually need into one turn. Never re-read a file
you hold a marker for.
Features β‘
- CCR compression - tool output becomes a compact
<<<CCR:hash|type|size>>>marker; the full content stays in the store until
you retrieve it. - TOML-driven templates -
[templates.preview.<family>.<ctype>]format
strings, a[templates.marker]block (format + hint),[templates.prompts]
session_inject, and a[templates.reverse]ctypeβkey remap. Resolution:
family[ctype]βreverse[ctype]βfamily[_default]β hardcoded builder. - Auto-expand -
[compression] auto_expandresolves just-stored content
inline instead of emitting a marker, capped byauto_expand_limit
(default 102400 bytes;APHRODITE_AUTO_EXPAND/APHRODITE_AUTO_EXPAND_LIMIT
override). - Context engine (default-on) - once the session passes
engine_threshold_pct(default 30) of context fill, overflowing middle
turns are archived and an engine_offload prompt is injected;
engine_protect_first/engine_protect_last/engine_min_msgsguard the
conversation edges; 100+ turns the engine off. - Live containers -
[compression] live_container(or
APHRODITE_LIVE_CONTAINER) turns large tool results into instantlive
CCR markers with progressive chunked retrieval and an ETA. - Prompt knobs -
retrieve_guidance,ccr_marker_hint, and
catalog_intent_hintstune how the system instructs the LLM about CCR. - Recursion & body caps -
[compression] recursive_depth/
APHRODITE_RECURSIVE_DEPTH(default 5) bounds nested expansion;
[compression] max_request_body_size/APHRODITE_MAX_REQUEST_BODY_SIZE
(optional, unset = no cap) bounds request bodies. - Rhai scripting (optional) - the
scriptingCargo feature links an
exact-pinned rhai 1.25.1 micro-script engine; the default build never pulls
it in.
Repositories
Aphrodite is split across two repositories - the parent monorepo owns the
Rust engine and the release pipeline; this repository is the thin Hermes
plugin that loads it.
| Repository | Role | Key paths |
|---|---|---|
| PlayForm/Aphrodite | Parent monorepo - Rust engine, binary proxy, docs, CI, releases. This plugin is a git submodule of it (plugins/aphrodite). | crates/aphrodite (core engine) Β· crates/aphrodite-hermes (dylib bridge) Β· vendor/headroom (owned fork) Β· .github/workflows/ (Build/Publish/Check) |
| PlayForm/Aphrodite-Hermes | This repository - the Hermes plugin (thin Python loader). No Rust, no compression logic; everything lives in the dylib built by the parent. | __init__.py Β· plugin.yaml Β· download.sh / download.ps1 Β· BINARY_VERSION Β· SHA256SUMS.txt |
Development model: the parent's Development branch accumulates the
Rust engine; this plugin's Development branch accumulates the loader. At
release time the plugin is synced first (submodule-first), then the parent
floats its gitlink to the plugin commit, and the parent tag drives
Build.yml (12 release assets) β Publish.yml (cargo publish). The
plugin's BINARY_VERSION names the binary release it expects; download.sh
fetches it from the parent's GitHub Release and verifies the in-tree
SHA256SUMS.txt.
See the parent's docs
for the engine, configuration reference, and the full release ceremony.
Installββ‘
Hermes plugin + explicit setup
Terminal
git clone https://github.com/PlayForm/Aphrodite-Hermes.git
cd Aphrodite-Hermes
ln -s "$(pwd)" ~/.hermes/plugins/aphrodite
bash download.sh # explicit setup step: binary + dylib from GitHub Releases
cd ..
hermes plugins enable aphrodite
hermes
The ln -s line links the plugin into ~/.hermes/plugins/ so Hermes can
discover it. Create it at install time - the plugin never creates, converts,
or recreates this link: ~/.hermes/plugins/aphrodite is Hermes-owned
(layout_check.py is report-only; the install path may be a symlink or a
real directory).
Binaries are never shipped inside the repository. The plugin downloads
them from the GitHub release (tag pinned in BINARY_VERSION, checksums
generated by Build.yml into the in-tree SHA256SUMS.txt) with an
explicit setup step - bash ./download.sh (or pwsh ./download.ps1 on
Windows) - which verifies SHA-256 against the in-tree checksum list and
refuses on mismatch. register() never downloads and never writes into
~/.hermes/plugins/aphrodite/: if the binaries are missing it logs the
setup command and the plugin stays disabled until they are present. No Rust
toolchain required.
[!IMPORTANT]
Native Windows: run
pwsh ./download.ps1instead ofdownload.sh- no
Git Bash/WSL needed. See
Windows install
for the full walkthrough, and
Troubleshooting
if the proxy doesn't come up after enabling the plugin.
LLM provider configuration (required)
The aphrodite proxy is an OpenAI-compatible LLM API proxy - it forwards
requests upstream - so it needs its own provider credentials even though
Hermes already has a provider configured. The plugin cannot read Hermes'
provider config, and there is no keyless / compression-only mode: without a
key the proxy refuses to start and the plugin is unusable.
Terminal
export APHRODITE_API_KEY="sk-..." # REQUIRED
export APHRODITE_API_URL="https://api.openai.com" # optional
export APHRODITE_MODEL="default-model" # optional
Alternatives: run aphrodite setup, or add api_key / api_url / model to
~/.hermes/aphrodite/aphrodite.toml. If the proxy fails to start,
~/.hermes/aphrodite/proxy-stderr.log shows the reason - no API key configured means the key is missing.
What changes after install
After installing and launching Hermes once:
Filesystem
~/.hermes/
βββ plugins/
β βββ aphrodite β /path/to/Aphrodite-Hermes β manual symlink to this repo
βββ aphrodite/
β βββ binaries/
β β βββ aphrodite β proxy binary (fetched by `download.sh` ~35 MB)
β β βββ libaphrodite_hermes.dylib β plugin dylib (fetched by `download.sh`)
β βββ ccr.db β SQLite CCR store (on first run)
β βββ proxy-stderr.log β proxy logs (on failure)
The plugin also adds to your Hermes config:
config.yaml
# Added automatically on enable
plugins:
enabled:
- aphrodite
# Recommended additions (manual)
context:
engine: aphrodite
engine_threshold_pct: 30 # % of context filled before archiving kicks in; 100+ = engine off
model:
context_length: 1000000
Two proxy processes launch on :9797 (cache) and :9798 (token).
On registration the plugin probes both health endpoints and reuses an
already-running proxy pair instead of launching a second instance.
Verify it's working
Terminal
# In a Hermes session:
aphrodite_stats
# Or via CLI:
curl http://127.0.0.1:9798/health
# β {"status":"healthy","version":"<installed binary version - see BINARY_VERSION>"}
Clean uninstall
Terminal
hermes plugins disable aphrodite
rm ~/.hermes/plugins/aphrodite # remove the manual symlink you created
pkill -f "$HOME/.hermes/aphrodite/binaries/aphrodite"
ArchitectureβποΈ
The plugin is a thin Python registration shim over a Rust dylib - every
hook, tool, and byte of compression logic lives in Rust. Python exists only to
load the dylib via ctypes and register its surface with Hermes.
Layers
Call chain
Hermes Agent (hooks + tool dispatch)
β
βΌ
plugins/aphrodite/__init__.py β ~1,150-line Python loader
β ctypes FFI, registers hooks/tools/engine - no logic
βΌ
libaphrodite_hermes.dylib β Hermes bridge (JSON contract)
β 6 hooks Β· 13 tools Β· schemas
βΌ
libaphrodite (core engine) β ALL compression logic
β hooks Β· resolve Β· retrieve Β· marker Β· preview
β stage2 Β· struct_extract Β· state Β· session
β catalog Β· prefetch Β· poll_worker Β· directives
β config_loader Β· templates Β· builtin_directives
β scripting (optional Cargo feature)
βΌ
CCR store (SQLite :9798 / in-memory :9797 / inline)
Data flow
Plugin mode
Tool executes β output intercepted by hook
β
classify β preview β store (SQLite / in-memory / inline)
β
Agent β [type:enriched preview] (not raw output)
β
aphrodite_retrieve(hash) β full content (only when needed)
Dual listeners
The plugin auto-launches two proxy processes (and reuses an already-running
pair instead of starting a second instance):
| Listener | Port | CCR backend | Threshold | Best for |
|---|---|---|---|---|
| Cache | :9797 | In-memory (DashMap, 10K entries) | >8 KB | Speed, transient sessions |
| Token | :9798 | SQLite (persistent) | >1 KB | Durability, tool relay |
Hooks
Six Hermes hooks drive the plugin (provides_hooks in plugin.yaml), all
dispatched to the Rust dylib:
| Hook | Role |
|---|---|
on_session_start | Engine bootstrap, directive seeding, proxy health check |
transform_tool_result | Compress every tool result before it reaches the LLM |
transform_terminal_output | Compress terminal output with exit-code context |
pre_llm_call | Inject directives, compress overflowing middle turns |
post_llm_call | Capture savings, update adaptive thresholds |
pre_tool_call | Prefetch-aware dispatch, auto-background slow calls |
[!NOTE]
No hot-reload: the dylib is resolved once per process from the installed
binary set and loaded directly (ctypes.CDLLon the canonical path). The
load is deterministic from the pinned tree - it never races a rebuild. To
pick up a new build, restart the Hermes session.
Toolsβπ οΈ
| Tool | Description |
|---|---|
aphrodite_retrieve | Resolve <<<CCR:hash|type|size>>> markers |
aphrodite_compress | Compress content via CCR with type hint |
aphrodite_stats | Proxy health, engine status, inline store size |
aphrodite_rebuild | Report binary/proxy version + a rebuild hint (does not rebuild or restart itself) |
aphrodite_files | Tracked file references grouped by tool |
aphrodite_diff | Conversation turn history with summaries |
aphrodite_search | Search CCR store by keyword or type |
aphrodite_directive | List/swap/add/remove/reset active behavioral directives |
aphrodite_test | Smoke test suite: quick (1 sample) or full (3 samples) |
aphrodite_catalog | Full CCR catalog with hashes, types, sizes, previews |
aphrodite_reclassify | Retroactive metadata enrichment |
aphrodite_prefetch | Read + compress files on demand; markers returned inline |
aphrodite_prefetch_status | Live prefetch schedule: loading, ready, errors |
ConfigurationββοΈ
All tuning in aphrodite.toml - searched in ./aphrodite.toml, then
~/.hermes/aphrodite/aphrodite.toml (when APHRODITE_CONFIG_PATH is unset):
aphrodite.toml
[compression]
engine_threshold_pct = 30 # % of context filled before middle-turn archiving; 100+ disables the engine
engine_protect_first = 2 # messages to keep at start
engine_protect_last = 5 # messages to keep at end
engine_min_msgs = 8 # minimum messages before the engine activates
tool_threshold_token = 256 # token proxy threshold (bytes)
tool_threshold_cache = 2048 # cache proxy threshold (bytes)
terminal_threshold = 256 # terminal output threshold (bytes)
inline_threshold = 1024 # inline-vs-durable CCR storage cutoff (bytes)
code_multiplier = 1.0 # 1.0 = code compresses at the base threshold
auto_expand = true # resolve just-stored content inline instead of emitting a marker
auto_expand_limit = 102400 # byte cap for auto-expanded content (0 = unlimited)
live_container = false # instant 'live' CCR markers for large tool results
recursive_depth = 5 # max nested expansion depth
# max_request_body_size = 10485760 # optional request-body cap (unset = no cap)
# Store retention (SQLite token proxy): ccr_ttl_seconds bounds the store in
# TIME, these bound it in SPACE. Past either cap the least-recently-accessed
# rows are evicted (a cache policy: an evicted hash is a retrieval miss, like
# an expired one). 0 = unlimited.
store_max_entries = 100000 # max live rows
store_max_bytes = 536870912 # max stored payload bytes
context_engine = true # engine status flag, default-on
[previews]
model_family = "code_first" # family selector for [templates.preview]; only matters when templates are configured
[prompts]
retrieve_guidance = "minimal" # prompt knob: how the LLM is told to use retrieval
ccr_marker_hint = false # prompt knob: marker hint text
catalog_intent_hints = false # prompt knob: per-intent catalog hints
[templates] # optional: format strings; absent = built-in builders
# preview.<family>.<ctype> = "format string"
# [templates.marker] format / hint
# [templates.prompts] session_inject
# [templates.reverse] ctype -> key remap
Env var overrides: APHRODITE_ENGINE_THRESHOLD_PCT, APHRODITE_CONTEXT_ENGINE,
APHRODITE_AUTO_EXPAND/APHRODITE_AUTO_EXPAND_LIMIT, APHRODITE_LIVE_CONTAINER,
APHRODITE_RECURSIVE_DEPTH, APHRODITE_MAX_REQUEST_BODY_SIZE, etc. Preview and
marker format variables, plus the resolution order, are defined in
crates/aphrodite/src/templates.rs.
See docs/config/env-vars.md.
Runtime home (one decision, shared by both halves)
The runtime home - where aphrodite.toml, binaries/, directives/,
ccr.db, and proxy-stderr.log live - is resolved by one shared
decision, made identically by the plugin shim and the Rust binary:
APHRODITE_HOME- explicit override; never second-guessed.<hermes-home>/aphrodite-$HERMES_HOMEwhen set (Docker image,
profile gateways), else~/.hermes/aphrodite.
At startup the shim exports its decision into APHRODITE_HOME (and
APHRODITE_DIRECTIVES_DIR), so the dylib and the spawned proxy binary
resolve the same directory by construction - the two halves cannot diverge.
The startup log names the result: runtime home: <path> (decided by APHRODITE_HOME override|HERMES_HOME|default).
Upgrading from β€ 2.1.5: when the Hermes-home-derived runtime home does
not hold an install but the pre-2.2 ~/.hermes/aphrodite does, the old home
is adopted (a one-line warning in the log) - nothing is migrated and
binaries/ / aphrodite.toml keep resolving. Adoption never fires for a
throwaway/scratch HERMES_HOME (e.g. the hermes plugins validate probe,
which must stay isolated from the real install). Set APHRODITE_HOME to pin
the location explicitly. The Rust binary follows the same resolution, so
standalone runs (aphrodite setup, proxy launches) agree even without the
shim.
Set APHRODITE_NO_AUTO_LAUNCH=1 to skip the proxy auto-launch entirely, e.g.
when a cargo watch dev loop runs the proxy itself.
Directives
Custom behavioral directives are name.md files in
~/.hermes/aphrodite/directives/ - an empty file means an intentionally
empty directive. The plugin does NOT ship a directives/ set: the binary
provides them (embedded builtins) and materializes them into the user-data
home at startup/setup, so the plugin dir stays a pure loader. The dylib
reads them from APHRODITE_DIRECTIVES_DIR (defaults to
~/.hermes/aphrodite/directives, user override wins). If no directive
directory is found, the compiled built-in set loads as a fallback - its
activation is logged. Manage them at runtime with aphrodite_directive
(list/swap/add/load/remove/reset).
Dev Install (Rust source)
Terminal
git clone https://github.com/PlayForm/Aphrodite.git
cd Aphrodite
cargo build -p aphrodite-hermes
# Dylib: target/debug/libaphrodite_hermes.dylib (crate aphrodite-hermes;
# `-p aphrodite` alone builds only the proxy binary). The loader resolves the
# dylib from the canonical runtime home first (env override
# APHRODITE_HERMES_DYLIB_PATH wins when set), so a dev loop copies it there:
mkdir -p ~/.hermes/aphrodite/binaries
cp target/debug/libaphrodite_hermes.dylib ~/.hermes/aphrodite/binaries/
An already-running dev proxy (cargo run -p aphrodite) that answers the
health endpoints is reused instead of relaunched - the plugin probes both
ports before launching (see _start_proxy).
Files
Layout
Aphrodite-Hermes/
βββ __init__.py β ~1,150-line Python loader (ctypes FFI)
βββ plugin.yaml β 13 tools, 6 hooks, context engine
βββ download.sh β Explicit binary fetch (macOS/Linux/Git Bash/WSL; optional - validates in-tree checksums)
βββ download.ps1 β Explicit binary fetch (native Windows PowerShell; optional)
βββ BINARY_VERSION β Pinned binary release tag
βββ SHA256SUMS.txt β In-tree checksums (GENERATED by Build.yml; download.sh verifies against this)
βββ tests/ β Plugin test suite
βββ README.md β This file
βββ .gitignore
Binaries are never stored in this directory and register() never
downloads: the plugin downloads from the GitHub release only via the
explicit download.sh / download.ps1 setup step into
~/.hermes/aphrodite/binaries/ (the canonical runtime home), validated
against the in-tree SHA256SUMS.txt (refuse on mismatch). The plugin never
modifies ~/.hermes/plugins/aphrodite/.
README from the reviewed commit 47e7fa3; it updates when the author re-pins.

PlayForm