Context Compression and Caching
Context Compression and Caching Hermes Agent uses a dual compression system and Anthropic prompt caching to manage context window usage efficiently across long
Hermes Agent uses a dual compression system and Anthropic prompt caching to manage context window usage efficiently across long conversations. Source files: (ABC), (default engine), , (session hygiene), (search for ) Context management is built on the ABC (). …
What this page covers
- Pluggable Context Engine
- Dual Compression System
- 1. Gateway Session Hygiene (85% threshold)
- 2. Agent ContextCompressor (50% threshold, configurable)
- Configuration
- Parameter Details
- Codex gpt-5.5 threshold autoraise
- Computed Values (for a 200K context model at defaults)
- Compression Algorithm
- Phase 1: Prune Old Tool Results (cheap, no LLM call)
- Phase 2: Determine Boundaries
- Phase 3: Generate Structured Summary
- Phase 4: Assemble Compressed Messages
- Iterative Re-compression
- Before/After Example
- Before Compression (45 messages, ~95K tokens)
- After Compression (25 messages, ~45K tokens)
- Prompt Caching (Anthropic)
- Strategy: systemand3
- How It Works
- Cache-Aware Design Patterns
- Enabling Prompt Caching
- Context Pressure Warnings
Section outline mirrored from the official Hermes Agent documentation. Follow any heading to read the complete text on the source site.
More in Developer Guide
Contributing
Thank you for contributing to Hermes Agent! This guide covers setting up your dev environment, understanding the codebase, and getting your PR merged. Contribut
Architecture
This page is the top level map of Hermes Agent internals. Use it to orient yourself in the codebase, then dive into subsystem specific docs for implementation d
Agent Loop Internals
The core orchestration engine is 's class — a large file that handles everything from prompt assembly to tool dispatch to provider failover. Core Responsibiliti
Prompt Assembly
Hermes deliberately separates: cached system prompt state ephemeral API call time additions This is one of the most important design choices in the project beca
Gateway Internals
The messaging gateway is the long running process that connects Hermes to 20+ external messaging platforms through a unified architecture. Key Files File Purpos
Session Storage
Session Storage Hermes Agent uses a SQLite database ( ) to persist session metadata, full message history, and model configuration across CLI and gateway sessio