Hermes compaction is how Hermes Agent shrinks a long conversation so it fits inside your model's context window: once a session hits the trigger, a separate summary call folds the older messages into one summary and keeps the newest messages word for word. It runs on its own by default, you can force it with /compress, and the v0.22.6 release added an opt-in setting called prepare_ahead that writes the next summary before you need it.
📺 Watch: 20 Hermes Agent Tips to make it 10X better!
🔥 Get the Agent OS as a free bonus: AI Profit Boardroom members get the full Agent OS zip, prompt libraries, daily tutorials and weekly live coaching calls. → Get inside
Hermes Agent is built by Nous Research. Everything on this page comes from the official Hermes docs and the v0.22.6 release notes published on GitHub on 2 November 2026.
If you want the copy-paste setups our members use to keep long agent sessions fast, they live inside the AI Profit Boardroom ($69/mo). If you want help planning how agents fit into your business, book a free AI strategy session.
What Hermes compaction does
Every model has a context limit. A long chat full of tool calls, file reads and terminal output fills that limit fast. When it gets full, the model slows down, costs more per turn, or stops answering.
Hermes fixes this by compressing the conversation. The docs call the feature context compression; compaction is the moment it fires. Here is the flow:
- Hermes watches how full the context is.
- At the trigger point, it takes the older middle of the conversation and sends it to a summarizer model.
- The summary replaces those older messages.
- The opening messages and the most recent messages stay as they were.
The summarizer is its own model call. By default it uses your main chat model. You can point it at a cheaper or faster model under the auxiliary compression settings, with auxiliary.compression.model and auxiliary.compression.provider.
Old turns are not thrown away. With the default compression.in_place set to true, the session keeps the same id and the pre-compaction turns are soft-archived under it. They stay searchable through session_search.
When Hermes compaction triggers
There are four ways a compaction starts.
- The size trigger. compression.threshold defaults to 0.50, so Hermes compresses at 50% of the model's context limit.
- An absolute cap. compression.threshold_tokens is off by default. Set it and Hermes compresses at whichever comes first, the ratio or the token count. The docs give 256000 as an example for compacting a 1M-window model at 256K instead of 500K.
- The idle trigger. compression.idle_compact_after_seconds is off by default. Set it to 1800 and a session you come back to after 30 minutes compacts before the first reply, so an old Telegram thread does not re-read its whole stale history every turn.
- Manual. You type /compress.
Automatic compaction is silent on chat platforms like Telegram, Discord and Slack. Turn on compression.progress_notices if you want to see the start and finish notices there. Failure notices and /compress feedback always show.
One edge case: if a plugin's pre_llm_call hook blocks a turn, that turn skips compaction completely. The hook runs before turn-start compaction. We cover that hook in our Hermes Agent hooks guide.
📺 Watch: Hermes Agent Just Got a FREE Second Brain!
Hermes compaction config keys
All compression settings live in config.yaml. There are no environment variables for them. These are the keys most people touch, with the defaults from the docs.
| Key | Default | What it does |
|---|---|---|
| compression.enabled | true | Turns compression on or off |
| compression.threshold | 0.50 | Compress at this share of the context limit |
| compression.threshold_tokens | null | Optional absolute token cap; the lower trigger wins |
| compression.target_ratio | 0.20 | Share of the threshold kept as the recent tail |
| compression.tail_mode | lean | How much recent history stays verbatim |
| compression.protect_last_n | 20 | Minimum recent messages kept uncompressed |
| compression.protect_first_n | 3 | Opening messages pinned across every compaction |
| compression.in_place | true | Keep the same session id after compaction |
| compression.idle_compact_after_seconds | 0 (off) | Compact a session that resumes after this much idle time |
| compression.prepare_ahead | false | Write the next summary in the background before the trigger |
| compression.proactive_prune_tokens | 0 (off) | No-LLM prune of old, bulky tool results |
A few notes on these:
- protect_first_n keeps your original goal visible. On a rolling session where the first turn no longer matters, the docs say to set it to 0.
- proactive_prune_tokens matters on big-window models, where the 50% trigger rarely fires and large tool outputs ride along every turn. The docs suggest 48000 as a starting value. It never calls a model.
- On a running gateway, edits to any compression key take effect on the next message. No restart.
Compaction is one half of keeping a session lean. The other half is what Hermes stores in memory, which we cover in the Hermes memory budget guide.
📺 Watch: NEW Hermes Agent Updates are INSANELY GOOD! 🤯
Using /compress for manual Hermes compaction
The /compress slash command compacts on demand. The docs list three forms:
- /compress summarizes the conversation now.
- /compress here N summarizes everything except the most recent N exchanges, which stay verbatim. N defaults to 2. You pick the boundary yourself.
- /compress followed by a focus topic narrows what the summary keeps.
Use it before you switch tasks inside one long session. Finish the research, run /compress with a focus on the findings, then start the build. The build turns get a short summary instead of fifty tool results.
In Bot Mode, each Bot in a group room has its own hidden room session. Group settings has a Compress history button per member that runs the same compression as /compress against that session.
Hermes compaction with prepare_ahead
This is the new part. The v0.22.6 release notes list "opt-in prepared compaction (compression.prepare_ahead)" in the window since v0.22.5.
What prepare_ahead does
Normally the summary is written at the moment compaction fires, so that turn waits on an extra model call. With compression.prepare_ahead set to true, Hermes writes the next summary in the background once the session gets close to the trigger. It does this while tools run and between turns.
When automatic compaction fires, Hermes checks the prepared summary still covers the same messages. If it does, it uses that summary instead of making a fresh summary call. Every message newer than the summary stays outside it, in the uncompressed tail.
The rules from the docs:
- One summary is prepared per compaction.
- Text edits by plugins are fine. A dropped message or a rewind breaks the match.
- If the summary is still being written when compaction fires, compaction waits for it within the usual time limit.
- If there is no prepared summary, or it no longer matches, compaction runs exactly as it would without the option.
- The developer notes say the background pass starts when the last prompt is within 12% below the trigger, and the setting is read when the agent is built, so it applies from the next session or gateway agent rebuild.
What prepare_ahead costs and where it does not apply
- It spends an auxiliary summary call that may go unused, for example after a rewind.
- It does not apply to manual /compress.
- It does not apply to plugin context engines.
- It does not apply to native or app-server compaction.
- With a memory provider that adds context to compaction summaries, it switches itself off after the first compaction, because every prepared summary would be thrown away.
Turn it on if your long sessions stall at the compaction turn and you are fine paying for a summary that sometimes goes unused. Leave it off if you run a memory provider that injects context into summaries, or if you mostly compact by hand.
How to get the new Hermes compaction setting
The release notes split it by install type:
- CLI: run hermes update, or re-run the installer one-liner.
- Microsoft Store app: updates through the Store.
- Docker and Hermes Cloud: nousresearch/hermes-agent:stable or :latest.
- Desktop app from the .exe or .dmg installer: no change in this release. It gets the update with the next bundled release.
Then add prepare_ahead: true under the compression block in config.yaml and start a new session.
If you are setting Hermes up for a team or a client and want a plan for models, memory and compaction together, grab a free AI strategy session. For the full map of how agents, skills and memory fit into one system, read the Agent OS guide. To see how different models handle long agent runs, Julian keeps his own model tests on Goldie Bench.
Hermes compaction FAQ
Does Hermes compaction delete my old messages?
No. With in_place set to true, which is the default, the pre-compaction turns are soft-archived under the same session id. They are marked inactive but stay searchable with session_search.
Can I use a cheaper model for compaction summaries?
Yes. Set auxiliary.compression.model and auxiliary.compression.provider. Leave the model empty to use your main chat model.
Does prepare_ahead work with /compress?
No. The docs say prepare_ahead does not apply to manual /compress, plugin context engines or native compaction. It only feeds automatic compaction.
Is prepare_ahead on by default?
No. It defaults to false. You opt in with compression.prepare_ahead set to true in config.yaml.
Want the setups, templates and weekly calls that keep your Hermes agents running? Join the AI Profit Boardroom. Want a one-to-one plan for using AI agents in your business? Book a free AI strategy session.











