hermes - 💡(How to fix) Fix ContextCompressor inflates small sessions, causing rapid re-compression and splits [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Root Cause

Root cause location

hermes-agent/agent/context_compressor.py:

  • _MIN_SUMMARY_TOKENS = 2000 (line ~52)
  • _compute_summary_budget() (line ~650–659)
  • compress() method does not bail out when the compressible window is not meaningfully larger than the summary budget.

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

Bug: ContextCompressor inflates small sessions, causing rapid re-compression and session splits

Symptom

When a Hermes session has very few historical turns, the context compressor can produce a summary that is larger than the uncompressed content it replaces. This triggers a vicious cycle:

  1. Compressor runs, summary is injected.
  2. Total token count increases instead of decreasing.
  3. On the next turn, compressor runs again, producing an even larger summary.
  4. Session splits occur roughly every ~20 minutes for affected users.

Users see the warning:

⚠ Compression summary failed: Request timed out… Inserted a fallback context marker.

Reproduction

  • Start a new session with a small compressible window (approx. 500–1000 tokens).
  • _MIN_SUMMARY_TOKENS is hard-coded to 2000 tokens inside ContextCompressor._compute_summary_budget().
  • Even when the actual compressible content is tiny, the summary budget floors at 2000 tokens.
  • The resulting structured summary contains metadata, formatting, and hedging language that together exceed the original turn count.

Root cause location

hermes-agent/agent/context_compressor.py:

  • _MIN_SUMMARY_TOKENS = 2000 (line ~52)
  • _compute_summary_budget() (line ~650–659)
  • compress() method does not bail out when the compressible window is not meaningfully larger than the summary budget.

Impact

  • Performance: unnecessary API calls for compression.
  • Reliability: session splits degrade user experience.
  • Cost: repeated summarisation of already-small contexts wastes tokens.

Environment

  • Hermes agent version: current main (2026-05-07)
  • Python 3.11
  • Affects all model providers (root cause is agent-side logic)

Proposed fix

Add a size-efficiency guard in ContextCompressor.compress():

  • Before generating a summary, compute whether compressible_tokens > (summary_budget + min_overhead).
  • If the window is too small to benefit, skip compression and return the original messages.
  • Regression tests should cover both "bails out" and "proceeds" branches.

Related

  • PR #21470 — implementation ready

Reported by thaenor / Mercury

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING