Context Compression and Caching
Context Compression and Caching
Start with meaning, then move to detail.
This lesson explains Context Compression and Caching as part of Hermes internals and extension points. You will learn what it does, when it matters, and the smallest safe test that proves it works.
If you are new, do not memorize names. Focus on three questions: what problem does this solve, what access does it need, and how can you verify the result?
For practice, inspect the first example, identify its effects, run it on test data, and compare the result with the source claim.
For advanced readers, inspect Pluggable Context Engine, Dual Compression System, 1. Gateway Session Hygiene (85% threshold), then verify failure modes and version compatibility.
Know Python, Git, and basic project structure before changing code.
A clear outcome before you read.
- Understand Context Compression and Caching without assumed prior knowledge.
- Separate the source description from what still needs testing in your environment.
- Read the first command and identify its inputs and outputs before copying it.
Short definitions before the details.
- Provider
- The service that runs or provides access and authentication to a model.
- Gateway
- The process that connects Hermes to channels such as Telegram or Discord and routes messages.
- Session & memory
- A session holds conversation context, while memory keeps selected facts that should persist.
What does the source say, and in what order?
- 01Pluggable Context Engine
Start here to understand the core idea or structure.
- 02Dual Compression System
Read this after the foundation, then connect it to the previous step.
- 031. Gateway Session Hygiene (85% threshold)
Read this after the foundation, then connect it to the previous step.
- 042. Agent ContextCompressor (50% threshold, configurable)
Read this after the foundation, then connect it to the previous step.
- 05Configuration
Read this after the foundation, then connect it to the previous step.
- 06Parameter Details
Read this after the foundation, then connect it to the previous step.
- 07In-place compaction (single stable session id)
Read this after the foundation, then connect it to the previous step.
- 08Per-model threshold overrides
Read this after the foundation, then connect it to the previous step.
- 09Codex gpt-5.5 threshold autoraise
Read this after the foundation, then connect it to the previous step.
- 10Codex app-server thread compaction
Finish here to verify the result and special cases.
Copy only after you understand the effect.
context:
engine: "compressor" # default — built-in lossy summarization
engine: "lcm" # example — plugin providing lossless context┌──────────────────────────┐
Incoming message │ Gateway Session Hygiene │ Fires at 85% of context
─────────────────► │ (pre-agent, rough est.) │ Safety net for large sessions
└─────────────┬────────────┘
│
▼
┌──────────────────────────┐
│ Agent ContextCompressor │ Fires at 50% of context (default)
│ (in-loop, real tokens) │ Normal context management
└──────────────────────────┘compression:
enabled: true # Enable/disable compression (default: true)
threshold: 0.50 # Fraction of context window (default: 0.50 = 50%)
# model_thresholds: # Per-model threshold overrides (substring match,
# "glm-5.2": 0.40 # longest key wins). See "Per-model threshold
# "claude-sonnet": 0.35 # overrides" below.
target_ratio: 0.20 # How much of threshold to keep as tail (default: 0.20)
protect_last_n: 20 # Minimum protected tail messages (default: 20)
min_tail_user_messages: 1 # Real user messages guaranteed in the Read the first command and identify its inputs and outputs before copying it.
Match every command to your installed Hermes version, review the files and accounts it can reach, and use non-sensitive data for the first test. If this explanation differs from the source, the official source wins.