← Back to blog

Hermes Agent cut 282 tokens per call by deleting prompts its memory tool already teaches

hermesprompt-engineeringtoken-efficiencysystem-promptcontext-compression
Hermes Agent cut 282 tokens per call by deleting prompts its memory tool already teaches

Hermes Agent runs a guidance block in its system prompt that tells the model how to use memory and skills. A PR merged on 2026-08-29 refactors that block and cuts the served token count from 537 to 255 per call, a saving of 282 tokens on essentially every session. The cut is not compression or truncation. It removes sentences that the memory tool's own schema already teaches on every call, so the agent loses no capability.

Why the text was redundant

The memory tool in Hermes Agent carries a schema that is sent to the model on every call. That schema already describes the save categories, the SKIP list (PR numbers, SHAs, task logs), and priority coaching. The old guidance block repeated all of that in prose. The refactor keeps only what the schema does not say.

SKILLS_GUIDANCE had a similar problem. It duplicated the ## Skills section of the system prompt and re-explained how to patch stale skills. The ## Skill Safety Rule was preserved but compressed to a single prose line: [SKILL_PRUNED] means the skill content was lost to compaction and must be reloaded via skill_view; the remaining [SKILL_PRUNED] markers in a session are historical artifacts, not a live signal.

"...it reteaches a lot of the skill_manage tool, repeats the ## Skills section, and should just focus on clean, concise memory instructions."

The numbers

Component Before After Saved
MEMORY_GUIDANCE ~300 130 ~170
SKILLS_GUIDANCE ~200 94 ~106
Combined served block (memory + session_search + skills) 537 255 282
Full desktop system prompt 5,311 ~5,002 ~309
Combined block reduction 537 to 255 52.5%

The combined block reduction is 282 of 537 tokens, or 52.5% (computed as (537 - 255) / 537 * 100). The full desktop prompt drops from 5,311 to about 5,002 tokens, a ~309-token saving once the rest of the diet is included. Three variants are emitted depending on which stores are enabled: default 130 tokens, profile-only 152, both-off empty.

What the new block says

The default variant, sent to nearly every session, reads:

You have persistent memory, carried across sessions and loaded into each
new session's context; the memory tool's schema defines what belongs there.
Save proactively - storage has a hard character budget, and when it fills,
replace or consolidate stale entries in the same batch rather than skipping
the save. Write entries as declarative facts, not instructions to yourself:
'User prefers concise responses' (ok) - 'Always respond concisely' (avoid:
imperative phrasing gets re-read as a directive in later sessions and can
override the user's current request). Route by longevity: a fact stale within
a week belongs in session history; procedures and workflows belong in skills.

Correctness fixes that rode along

The refactor also fixed wording that was technically wrong. The old prompt said memory is "injected into every turn." It is not. Memory is snapshotted at session load and is byte-stable for the session, the same caching invariant that lets the agent avoid re-reading it each turn. The new text says memory is "carried across sessions and loaded into each new session's context."

A single builder function now produces the guidance: build_memory_guidance(memory_enabled, profile_enabled). The opening frame adapts to which stores are configured (default, profile-only, or both-off) without duplicating the body text. Legacy constant names survive as aliases so downstream code does not break.

Verification

The PR shipped with pin tests rewritten to lock the dieted contracts, including the safety rule and the form rule, plus the #82154 content-filter REJECTED_FRAGMENTS parametrization left untouched. The offline AIAgent build check confirmed the safety rule with heading present, schema-taught curricula absent, the wrong "every turn" phrase absent, and the positive lead pinned. Test result: 111 passed, 1 skipped.

The saving is small in absolute terms against a multi-thousand-token prompt, but it is free: the same instructions now live in the tool schema that already accompanies every call, so the model sees them whether or not the prose repeats them.

Termagotchi
_

Ryan Underdown

Autodidact. Rarely listens to advice.

Follow on X @catamarammed or GitHub @underdown