Guides

Hermes Integration

loads the plugin atgateway startsix hooks, thirteentoolsspawns on pluginloadCCR markers,directives, catalogCCR storeHermes Agentaphrodite plugin - pure loaderlibaphrodite_hermes.dylibproxy subprocesses on :9797 and :9798~/.hermes/aphrodite runtime home
GUIDES/HERMES-INTEGRATION
IN THIS DOCUMENT

Crimson marks the heading currently in view; every entry is one of the document's own headings.

Aphrodite connects to Hermes Agent as a native plugin, not as a proxy you point a client at.

It is the reason the interception lives inside the turn: tool output never hits a wire, so only hook-level registration can catch it before it becomes message history.

The plugin is a thin Python loader: it registers six hooks, thirteen tools, and an optional context engine with Hermes, then forwards every call into a Rust dylib that holds all of the actual behavior.

Two proxy processes - a cache proxy and a token proxy - run alongside as subprocesses, and a canonical runtime home under ~/.hermes/aphrodite/ holds the binaries, config, CCR database, directives, and logs.

loads the plugin atgateway startsix hooks, thirteentoolsspawns on pluginloadCCR markers,directives, catalogCCR storeHermes Agentaphrodite plugin - pure loaderlibaphrodite_hermes.dylibproxy subprocesses on :9797 and :9798~/.hermes/aphrodite runtime home
GUIDES/HERMES-INTEGRATION

The plugin is a pure loader

The plugin directory ships no binaries.

It contains the loader (__init__.py), the generated FFI bindings (_bindings.py), the download scripts (download.sh / download.ps1), the layout checker (layout_check.py, report-only), and plugin.yaml.

All logic lives in libaphrodite_hermes.dylib, which the loader resolves once per process (no hot-reload) and smoke-tests in a subprocess before loading (a faulting image degrades to a graceful “plugin disabled” instead of killing the gateway).

Registration is driven by the dylib: the shim asks the dylib for its hook names and tool schemas and registers one callback per name, so the hook set and tool set are always registered together and a broken callback is isolated without failing the others.

plugin.yaml declares the same six hooks and thirteen tools for Hermes’ manifest.

Hooks

Six hooks connect Aphrodite to the agent loop. Each is a thin dispatch that forwards its arguments to the dylib and hands the JSON reply back to Hermes.

HookWhen it firesWhat Aphrodite does
on_session_startA Hermes session startsReset per-session state: turn counter, conversation index, markers, nudges
pre_tool_callBefore a tool executesAuto-background long-running calls; split chained commands (opt-in)
transform_tool_resultAfter every tool callClassify the result, compress above threshold, replace it with a CCR marker
transform_terminal_outputAfter every terminal executionSame pipeline for shell stdout/stderr
pre_llm_callBefore each LLM requestInject directives, nudges, and the recall catalog under a hard byte budget
post_llm_callAfter each LLM responseArchive the turn, advance the counter, expire nudges and stale tasks

transform_tool_result is where tool output becomes a marker: the hook classified the result into a content type, hashed it (BLAKE3), stored it, and replaced it with a marker of the form <<<CCR:hash|type|size>>> with a compact preview.

The agent can recover the exact original bytes with aphrodite_retrieve.

See Plugin Hooks for the full per-hook reference.

Tools

The plugin registers thirteen aphrodite_* tools from the dylib’s schemas: retrieve, compress, stats, rebuild, files, diff, search, directive, test, catalog, reclassify, prefetch, and prefetch_status.

They teach the agent how to interact with the CCR engine - retrieving stored content, inspecting the catalog, adjusting directives - and auto_expand expands them inline rather than compressing them.

See Tool Relay: Tools for the reference.

Context engine

The plugin declares context-engine support and can register a Hermes context engine when opted in with APHRODITE_CONTEXT_ENGINE=1.

By default no engine is registered: the pre_llm_call hook injects the per-turn catalog summary instead, so the context assembler remains the single source of what the model sees.

See Context Engine for details.

Runtime home

The canonical runtime home is ~/.hermes/aphrodite/:

$HERMES_HOME/ (default ~/.hermes/)
├── plugins/
│   └── aphrodite/          ← Hermes-owned install location (symlink or dir)
└── aphrodite/              ← canonical runtime home
    ├── aphrodite.toml      ← engine and proxy config
    ├── binaries/           ← proxy binary + dylib (fetched by the explicit
    │                         download.sh / download.ps1 setup step)
    ├── ccr.db              ← SQLite CCR store (created on first run)
    ├── directives/         ← active directive files
    └── logs/               ← proxy and engine logs

On plugin startup layout_check.py checks toward this schema but is report-only: it logs deviations and never moves them - and the plugins/aphrodite install path is Hermes-owned (the plugin never creates or recreates it).

The plugin directory stays a pure loader.

Proxy subprocesses

Two proxies launch when the plugin loads:

  • a cache proxy on :9797 (in-memory backend, compresses payloads above 8 KB)
  • and a token proxy on :9798 (SQLite backend, compresses above 1 KB).

The plugin guards the launch - it probes both health endpoints first and skips launching when a healthy proxy already owns the ports, and APHRODITE_NO_AUTO_LAUNCH disables auto-launch entirely.

Each proxy compresses HTTP response bodies for OpenAI-compatible clients; the Hermes plugin path compresses locally through the hooks and does not depend on the proxies for its own compression.

Why not just a proxy?

A generic proxy compresses HTTP response bodies. That helps, but:

  1. Tool output never hits the wire. Hermes tool calls run locally. transform_tool_result intercepts the return value before it becomes part of the message history. A proxy cannot see this.
  2. Terminal output is local. transform_terminal_output catches shell command stdout/stderr before Hermes processes it. The proxy has no visibility.
  3. The agent is augmented, not just compressed. The thirteen aphrodite_* tools teach the agent how to use the CCR engine, and pre_llm_call injects directives, nudges, and the recall catalog. A proxy is opaque - the agent does not know compression exists.
Native Hermes pluginGeneric proxy (any client)
How it worksHook registration in plugin.yamlPoint base_url at :9798
Tool output compression✅ transform_tool_result intercepts❌ proxy only sees HTTP traffic
Terminal compression✅ transform_terminal_output❌
Context engine✅ opt-in; catalog injected via pre_llm_call❌
Auto-launch✅ proxies spawn at plugin load❌ manual aphrodite command
aphrodite_* tools✅ 13 tools in agent namespace❌ agent doesn’t know about them
Prompt injection✅ directives, nudges, catalog❌
CCR storage✅ token + cache proxy✅ token + cache proxy
Works withHermes onlyAny OpenAI-compatible client
Setuphermes plugins enable aphroditeOPENAI_BASE_URL=http://localhost:9798

What each configuration buys

Three configurations, three trade-offs - each buys something the previous one does not have:

Hermes alone.

Nothing intercepts tool output.

Every file read, build log, and JSON blob enters the message history raw, because nothing stands between the tool and the model - the agent spends its token budget reading noise instead of reasoning.

Hermes + Aphrodite.

The plugin lane intercepts output before it becomes message history: transform_tool_result classifies, stores, and replaces raw output with a type-aware marker (~15 tokens instead of hundreds), the agent retrieves the full content only when it actually needs it, and pre_llm_call injects directives, nudges, and the recall catalog under a hard byte budget.

Measured over 200 real Hermes sessions: 26.9% of all context tokens deflected, a median session saved ratio of 22.9%, and ~22,921 tokens saved per API call.

The trade-off is stated plainly: the hooks are Hermes’ contract - no other client can register them, so this lane works with Hermes only.

Hermes + Aphrodite + the Aphrodite proxy.

The plugin already spawns both listeners, so the third configuration runs without extra setup: point base_url at :9798 and any OpenAI-compatible client gets the same CCR compression over plain HTTP.

That is the agent-to-agent path - a second agent, a script, or an external tool can converse through the same compressed channel, share the persistent SQLite store (which survives a restart; the plugin lane’s inline store is session-scoped), and call the tool relay to retrieve or create CCR entries.

The limit is real too: the proxy only sees HTTP traffic - no tool-output interception, no terminal compression, no directives, no context engine, and SSE streams pass through uncompressed.

The proxy extends the stack to other callers; it does not replace the hooks inside Hermes.

What the agent sees

Without Aphrodite, the agent’s context fills with raw tool output:

500 tokens of build output... scrolling... error? no... warning? no...
ok it passed. That was 500 tokens I'll never get back.

With native Hermes integration, transform_tool_result replaces it:

[build:0E 0W 1L]  ← a few tokens. The agent knows: build passed.

The agent retrieves the full output with aphrodite_retrieve(hash) only when it actually needs it - for clean builds, exit=0 terminals, and small diffs, the preview is enough.

Setup

There are three install paths - the Hermes plugin with an explicit download.sh / download.ps1 setup step (recommended), cargo install aphrodite + aphrodite setup, and building from source.

See Installing Aphrodite for the full walkthrough and per-platform details.

Short version for the plugin path:

git clone https://github.com/PlayForm/Aphrodite-Hermes.git
ln -s "$(pwd)/Aphrodite-Hermes" ~/.hermes/plugins/aphrodite
hermes plugins enable aphrodite
hermes # restart so the plugin loads fresh

Before enabling the plugin, run the explicit setup step - bash download.sh (or pwsh ./download.ps1 on Windows) - which fetches the binary + dylib into ~/.hermes/aphrodite/binaries/, SHA-256 verified against the in-tree SHA256SUMS.txt.

register() never downloads: if the binaries are missing it logs the setup command and the plugin stays disabled until they are present.

No Rust toolchain needed.

See also