Hermes Agent

How-To Guide

Configure Context Compression — Handle Long Conversations

Inspect Hermes context with /context, configure in-place compression, and recover long conversations without confusing context pressure with memory loss.

Quick answer

Run /context before compressing. Current Hermes uses in-place compression by default, so /compress summarizes older turns while keeping the session ID and soft-archiving prior messages. Compression is lossy; preserve critical decisions, use an auxiliary model with enough context, and verify recall afterward.

Long conversations eventually pressure the model's context limit. Hermes can summarize older turns and keep the current session ID, but compression is lossy: inspect /context, protect critical decisions, and verify recall after the summary instead of assuming nothing can be lost.

Deploy Hermes faster with FlyHermes

Managed cloud · API costs included · Skill library · Cancel anytime

Before you start:

  • Hermes Agent installed
  • Understanding of token limits and context windows

Steps

  1. 1

    Inspect context before compressing

    On Hermes Agent v0.20 or newer, run /context to separate system prompt, tools, skills, memory, conversation, and free space. Use /context all for per-skill and per-toolset costs, then decide whether to compress, remove duplicated context, or start a focused session.

  2. 2

    Enable compression

    In config.yaml, set compression: enabled: true

  3. 3

    Set the threshold

    Set compression: threshold: 0.50 to compress at 50% of context limit

  4. 4

    Configure target ratio

    Set compression: target_ratio: 0.20 to preserve 20% as recent context

  5. 5

    Protect recent messages

    Set compression: protect_last_n: 20 to always keep last 20 messages intact

  6. 6

    Choose a compression model (optional)

    Configure auxiliary.compression.provider, model, and timeout deliberately. The summary model must have a context window at least as large as the main agent model. Add fallback_chain if the primary auxiliary route can hit credits, payment, or capacity errors.

  7. 7

    Keep the session identity stable

    Leave compression.in_place: true unless you intentionally need legacy continuation sessions. In-place compression keeps the active session ID and soft-archives older turns while rebuilding the compacted context.

  8. 8

    Choose legacy or lean tail retention

    Keep compression.tail_mode: legacy for the established verbatim-tail behavior. Use lean when very large windows make the retained tail too expensive: lean keeps a smaller clamped tail, identifier anchors, real user messages, and a session-search recovery pointer. Test recall on a copy of a real long session before changing production.

Pro Tips

  • 💡Lower threshold values trigger compression earlier — use 0.50 for aggressive compression, 0.80 for late compression
  • 💡The first 3 turns (system prompt, initial request, first response) are always protected
  • 💡Compression uses an auxiliary model route; verify its provider, credits, latency, and context window instead of assuming the cheapest model is safe
  • 💡Use /compress <focus> to manually trigger compression with a specific focus topic
  • 💡If compression succeeds but recall is still wrong, use the memory troubleshooting decision tree to separate active context from durable memory, session history, profiles, and external providers.
  • 💡Use /compress here 2 to summarize older context while keeping the latest two exchanges verbatim; change 2 when a different boundary is safer.
  • 💡A full MEMORY.md is not a reason to compress more aggressively; durable memory capacity and active conversation pressure are separate limits.

Troubleshooting

Agent forgets important earlier context

Increase protect_last_n to keep more recent messages. Also ensure critical information is in MEMORY.md for persistent recall.

Compression happens too often

Increase threshold from 0.50 to 0.70 or 0.80 to delay compression until more of the context window is used.

Compression summaries are low quality

Change the compression model to a higher-quality option: auxiliary: compression: model: anthropic/claude-3-haiku

Context pressure warnings but no compression

Check that compression: enabled: true is set. Also verify your model's context_length is correctly detected.

Compression times out and retries on every message

Update Hermes, inspect auxiliary.compression, choose a faster model with enough context, raise its timeout if needed, and configure a fallback chain for capacity or payment failures.

Hermes loops even though context is below the compression threshold

Do not repeatedly force compression. Run /context, /status, /model, and /tools list, update Hermes, then replay one tiny tool task in a fresh session and on one alternate model/provider to separate session state from model tool-use behavior.

FAQ

What does context compression do?

It summarizes older conversation turns when you approach the model's context limit, freeing room for new messages while keeping the important context — so conversations don't hard-stop or silently lose the thread.

Does compression lose information?

It trades fidelity on old turns for length. Critical facts should also live in persistent memory, which survives compression; compression manages the live context window, not long-term storage.

How does it affect cost?

It keeps the working context from ballooning, which steadies token usage on long sessions. Pair it with session reset policies for tighter cost control.

Will `/compress` fix every repeated-tool loop?

No. Compression helps when active context is crowded. If /context shows substantial free space, test the runtime, tool inventory, and model/provider with one controlled fresh-session replay instead.

What is Hermes lean compression tail mode?

Lean mode retains a smaller verbatim tail and carries continuity through structured summaries, identifier anchors, real user messages, and a session-search recovery pointer. It is aimed at very large contexts where legacy tails remain expensive.

Related Guides