← Back to blog

Crystal Compactor: 93.7% Context Reduction Across a 600-Tool-Call Agent Session

hermescontext-compressiontoken-optimizationcrystalagent-reliability
Crystal Compactor: 93.7% Context Reduction Across a 600-Tool-Call Agent Session

On July 28, Hermes user @M3NT8L published a benchmark of the Crystal compactor — Hermes Agent's context compression layer — from a four-hour session. The session ran approximately 600 tool calls alongside parallel Apple app development work. The compactor reduced active history by 93.7% while maintaining full continuity across all 59 turns.

The numbers come from Crystal's self-diagnostic "Crystal Doctor" report, which tracks compaction health, facet integrity, and maintenance debt. All measurements are from a single long-running agent session.

The compression benchmark

Metric Value
Session duration ~4 hours
Meaningful turns 59
Tool calls ~600
Context replacements performed 38
Older messages removed 5,614
Crystallizer passes 9
Facet maintenance calls 35/35 succeeded
Latest compaction speed ~11 ms
Fallbacks or errors 0
Crystal Doctor status HEALTHY

The compression itself:

Token pool Count
Source history tokens ~4,170,000
Replacement tokens (compressed) ~262,520
Gross reduction 93.7%

The compactor did not simply truncate or naively summarize. The condensed output preserved specific issue references (issue #19 freeze, issues #24 through #27), iPad reference behavior, Git publication gates, and checksum matches. The Crystal Doctor self-detected minor maintenance debt — duplicate status lines and slightly stale wording — and queued remediation for the next maintenance pass.

How Crystal works

Crystal is distinct from the four-layer memory architecture (SOUL.md, frozen snapshots, memory blocks, session FTS5) that Hermes ships with natively. While that stack manages what the agent knows across sessions, Crystal manages what stays in active context during a single long session.

It runs periodic Crystallizer passes that distill accumulated conversation history into dense replacement tokens. Instead of letting the context window fill until the model silently loses early information, Crystal performs scheduled compactions — 11 ms each in the benchmark — that collapse old messages while preserving continuity.

The system maintains specialized data structures called facets. Each facet tracks a different category of state: issue references, file paths, deployment status, checksums. During a Crystallizer pass, Crystal extracts and preserves the canonical value for each facet, then replaces the verbose source messages with a compact representation. The 35/35 facet maintenance success rate in the benchmark means every tracked state value survived every compaction.

Crystal also runs a self-diagnostic called the Crystal Doctor. It checks for stale locks, registry mismatches, orphan sessions, and maintenance debt. When it finds issues, it either resolves them immediately or queues them for the next pass. In the benchmark, the Doctor reported HEALTHY with no stale locks or registry inconsistencies.

Why this matters for long-running agents

The standard failure mode for long-horizon agents is context saturation. As tool calls and turns accumulate, the model's context window fills with history. At some point the oldest — often the most structurally important — instructions fall out. The agent starts making decisions without the original constraints.

Three approaches exist for this problem:

  1. Larger context windows. This just delays the problem. A 1M-token window fills at the same rate as a 128K-token window — it just takes longer to hit the cliff.

  2. Summarization. The model summarizes old conversation turns into shorter text. This works but loses precision. Summaries tend to flatten specific technical details — exact error messages, file paths, issue numbers — into vague descriptions.

  3. Collaborative compression. Crystal's approach. Instead of asking the model to summarize, Crystal extracts structured state (facets) from old messages and maintains them as canonical values. The source messages are then replaced with compact references. The agent never sees a degraded summary — it sees exact, current values for every tracked state dimension.

"Crystal is collaborative compression: the agent, layered files, search, and Crystal work together instead of blindly thresholding and discarding context."

@andrexibiza, in a thread about Hermes context engineering, July 28, 2026

The 93.7% figure is notable not because compression is hard — summarization can hit similar ratios — but because the benchmark reported zero continuity breaks. The agent continued working on the same issues, with the same context, across 38 compactions, without losing track of what it was doing.

Relationship to the broader context engineering stack

Crystal sits alongside the layered memory architecture that the Hermes community has been developing. @rlaope documented the full stack: L0 SOUL.md (permanent identity), L1 frozen snapshots (immutable session summaries), L2 budgeted memory blocks (6,000-char cap per block), and L3 session FTS5 (full-text search on current session).

Crystal operates primarily on L3 — the live session log — and feeds condensed results into L1 and L2 for cross-session persistence. The result is a pipeline: raw conversation turns get compacted during the session, then frozen snapshots and labeled memory blocks carry the compressed state forward to future sessions.

@andrexibiza made the argument that, in practice, more context is often worse. Custom external memory providers, large instruction files, and accumulated patches create synchronization debt. Resetting to documented defaults plus tight layering — SOUL.md, AGENTS.md, MEMORY.md, and skills — frequently yields better results than elaborate custom stacks.

The 5,614 older messages Crystal removed from the active history in this session represent exactly the kind of bloat that accumulates when long-running agents carry full history forward. Without Crystal, those messages would either consume the context window or be lost entirely when the window overflowed.

Practical implications

The benchmark suggests a few operational takeaways:

  • Compaction speed is not a bottleneck. At 11 ms per pass, Crystal can run compactions inline without perceptible latency to the user. Nine passes across four hours averages one every 27 minutes — frequent enough to prevent buildup.

  • Facet integrity is the right metric. The 35/35 facet maintenance score is more meaningful than the raw compression ratio. If facets drop state, the agent loses context regardless of how much compression was achieved. The benchmark shows Crystal maintained perfect facet fidelity.

  • Self-diagnosis catches drift. The Crystal Doctor flagged maintenance debt (duplicate status lines, stale wording) that had not yet caused problems. This is proactive detection rather than reactive cleanup — the system identifies and schedules fixes before they affect agent behavior.

The broader field is converging on similar approaches. Meta and CMU published work on Agentic Context Management in the same timeframe, giving agents tools to decide when and what to compress rather than using static token thresholds.[^1] Crystal represents a working implementation of that principle inside a production agent framework.

[^1]: @omarsar0. Agentic Context Management — Meta/CMU research, July 2026.

Termagotchi
_

Ryan Underdown

Autodidact. Rarely listens to advice.

Follow on X @catamarammed or GitHub @underdown