INDEX 10 / 14

HERMES // THE INTEGRATION

Living inside Hermes

A tool call's output becomes part of the model's context, and the model reads and pays for every line of it.

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 - six hooks, thirteen tools, and an optional context engine, every call forwarded into the Rust dylib.

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

01 // THE BASELINE // HERMES ALONE

What a raw turn costs

NO INTERCEPTION

HERMES ALONE - nothing stands between a tool and the model.

That is the baseline cost the other two configurations exist to remove.

WHAT ENTERS THE HISTORY

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

02 // THE SURFACE // CAPABILITY BY LANE

The integration surface, capability by capability

01 // HOOKS

6 hooks

Around every turn: pre_tool_call → transforms → pre_llm_call → post_llm_call.

02 // TOOLS

13 tools

In agent namespace - through the proxy the agent doesn't know about them.

03 // PROXIES

2 proxies

Two proxy processes still run alongside as subprocesses.

04 // ENGINE

1 engine

Optional third integration point: APHRODITE_CONTEXT_ENGINE=1 turns it on.

HOOKS // 6
on_session_starttransform_tool_resultpre_llm_calltransform_terminal_outputpost_llm_callpre_tool_call
TOOLS // 13
aphrodite_retrieveaphrodite_compressaphrodite_statsaphrodite_rebuildaphrodite_filesaphrodite_diffaphrodite_searchaphrodite_directiveaphrodite_testaphrodite_catalogaphrodite_reclassifyaphrodite_prefetchaphrodite_prefetch_status
COMPARISON // WHY NOT JUST A PROXY CAPABILITY × LANE 7 CAPABILITIES
CAPABILITYNATIVE HERMES PLUGINGENERIC PROXY
Tool output compressiontransform_tool_result interceptsproxy only sees HTTP traffic
Terminal compressiontransform_terminal_outputno visibility
Context engineopt-in; catalog injected via pre_llm_callunavailable
Auto-launchproxies spawn at plugin loadmanual aphrodite command
aphrodite_* tools13 tools in agent namespaceagent doesn't know about them
Prompt injectiondirectives, nudges, catalogunavailable
CCR storagetoken + cache proxytoken + cache proxy

03 // TWO LANES // THE PLUGIN AND THE PROXY

The lane inside Hermes, and the lane beside it

THE PLUGIN LANE
INSIDE THE TURN HOOK-LEVEL

HERMES + APHRODITE - the plugin lane intercepts output before it becomes message history.

The hooks classify, store, and replace raw output with a type-aware marker of ~15 tokens instead of hundreds, the agent retrieves the full content only when it actually needs it, and the injection assembler adds directives, nudges, and the recall catalog to every turn under a hard byte budget.

THE PROXY LANE
BESIDE THE TURN HTTP ONLY

HERMES + APHRODITE + THE PROXY - the plugin already spawns both listeners, so the third configuration is running 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.

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

04 // THE RESULT // SAVED AND PAID FOR

What it saved, and what it costs

22.9%

MEDIAN SESSION SAVED RATIO

~22,921

TOKENS SAVED PER API CALL

200

REAL HERMES SESSIONS

05 // LIFECYCLE // SESSION TO SESSION

What happens when you launch Hermes

hermes starts ONCE PER PROCESS BOOT SEQUENCE
→ plugin loads · dylib resolved once per process, smoke-tested in a subprocess
→ a faulting image degrades to "plugin disabled" instead of killing the gateway
→ two proxies spawn - a healthy pair is reused, never duplicated
→ on_session_start resets all per-session state
→ turn loop: pre_tool_call → transforms → pre_llm_call → post_llm_call
→ session ends · markers do not survive a restart - a new session starts a fresh store

THE DUAL PROXIES

TOKEN :9798 1 KB
SQLite. Persistent. Compresses above 1 KB.
CACHE :9797 8 KB
In-memory. Compresses above 8 KB.
NO HOT-RELOAD

RESTART THE SESSION TO PICK UP A NEW BUILD.

next turnthe session starts:on_session_start resetsthe dylib is loaded once per processturns run through the 6-hook chain:large outputs become markersretrieve only when detail is neededthe context fills:the engine records usagevia update_from_responseclose or restart:a hard reset - no session-endhook existsa fresh store, no hook firesevery prior marker becomesunresolvable at oncea rebuilt dylib takes effectonly after the session restartsRESTART
M8 // SESSION LIFECYCLE

06 // EVIDENCE // WHAT THE AGENT SEES

The twelve preview shapes

PREVIEW SHAPES 12 ARMS REPRESENTATIVE NUMBERS
[build: 1E 1W 142L | error[E0432]: unresolved import ...]
[diff: 4F +7/-3 12L | src/main.rs Cargo.toml +2 more]
[git: 2M 2A 1D 3?? | src/x.rs src/y.rs +6 more]
[gitlog: 2 commits | abc1234 fix... → def5678 feat...]
[ls: 3 files 2 dirs | .rs×2 .md×1]
[test: 220 pass 0 fail 1 ignored | 0.31s]
[grep: 4 hits in 3 files | src/preview.rs:12 ...]
[code: 3fns|2structs fn main() 414L]
[search: 4 hits in 3 files | src/x.rs:12 ...]
[json: 5items 3L]
[terminal: 14L exit code: 0]
[text: 3L 50B | some unrecognizable prose here]

Each line is the format string its own arm prints, character for character: the tallies come first, then whatever the arm could add about them. The extension counts in an ls line are joined with × rather than a letter x, a JSON item count is set tight against the word it counts (5items), a code map joins its structure parts with a pipe, and a search line reports hits, distinct files and the first match location. The numbers are representative; the shapes are the code's, which is what makes them checkable against preview/builders/*.rs rather than taken on trust.

WITHOUT APHRODITE 500 TOKENS ≈ 2,000 CHARS
500 tokens of build output... scrolling... error? no... warning? no... ok it passed. That was 500 tokens I'll never get back.
WITH NATIVE INTEGRATION A FEW TOKENS 44 LINES
[build:0E 0W 44L] ← a few tokens. The agent knows: build passed. The line count is the same log that costs 500 tokens raw: five hundred tokens is about two thousand characters, which is what forty-four lines of compiler output measure.
SANITIZED · GENERALIZED

SANITIZED, GENERALIZED SHAPES - REPRESENTATIVE PREVIEW FORMS FROM THE PUBLIC DOCS, NOT SESSION CONTENT.

RETRIEVAL ON DEMAND

THE AGENT RETRIEVES FULL OUTPUT WITH aphrodite_retrieve(hash) ONLY WHEN IT ACTUALLY NEEDS IT.

07 // OPT-IN // CONTEXT ENGINE

The optional third integration point

Enable with APHRODITE_CONTEXT_ENGINE=1 .

The engine is the session's middle-turn archiver: when the conversation index fills past engine_threshold_pct , it packs the middle turns (keeping engine_protect_first at the start and engine_protect_last at the end, once engine_min_msgs turns exist) into one compact CCR entry and replaces them with a single marker, so the model sees a short head + marker + tail history.

The archive is in-place but recoverable via aphrodite_retrieve.

ENGINE KEYS 4 DEFAULTS aphrodite.toml
engine_threshold_pct
30
# archive middle turns at % context fill
engine_protect_first
2
# messages kept at the start
engine_protect_last
5
# messages kept at the end
engine_min_msgs
8
# minimum messages before activating

SRC: README.md:91-99, 219-299, 467-482; docs/guides/hermes-integration.md:115-141; docs/proxy/architecture.md:12-31; docs/tool-relay/callbacks.md:89-92.

SRC: README.md:298-299; docs/guides/hermes-integration.md:107-108.