Academy → Developer guideOfficial documentation · clear explanation

Context Compression and Caching

Context Compression and Caching

Developer21 minutes3 questions2026-08-09
The idea in one minute

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

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 hands-on use

For practice, inspect the first example, identify its effects, run it on test data, and compare the result with the source claim.

For specialists

For advanced readers, inspect Pluggable Context Engine, Dual Compression System, 1. Gateway Session Hygiene (85% threshold), then verify failure modes and version compatibility.

What do you need first?

Know Python, Git, and basic project structure before changing code.

What will you know?

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.
Lesson terms

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.
Topic map

What does the source say, and in what order?

  1. 01
    Pluggable Context Engine

    Start here to understand the core idea or structure.

  2. 02
    Dual Compression System

    Read this after the foundation, then connect it to the previous step.

  3. 03
    1. Gateway Session Hygiene (85% threshold)

    Read this after the foundation, then connect it to the previous step.

  4. 04
    2. Agent ContextCompressor (50% threshold, configurable)

    Read this after the foundation, then connect it to the previous step.

  5. 05
    Configuration

    Read this after the foundation, then connect it to the previous step.

  6. 06
    Parameter Details

    Read this after the foundation, then connect it to the previous step.

  7. 07
    In-place compaction (single stable session id)

    Read this after the foundation, then connect it to the previous step.

  8. 08
    Per-model threshold overrides

    Read this after the foundation, then connect it to the previous step.

  9. 09
    Codex gpt-5.5 threshold autoraise

    Read this after the foundation, then connect it to the previous step.

  10. 10
    Codex app-server thread compaction

    Finish here to verify the result and special cases.

Examples from the official page

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
Try it now

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.

Knowledge check

Three decisions before completion.

1. What is the source of truth when “Context Compression and Caching” changes?
2. What is the best way to apply this lesson?
3. What should happen before a step can modify files or an external account?