hermes - ๐Ÿ’ก(How to fix) Fix [Bug]: Context Compression Failure [2 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โ€ฆ

Error Message

This issue occurs when the auxiliary LLM provider returns a non-JSON response (plain text, HTML error page, or malformed JSON) instead of a valid JSON response. The OpenAI-compatible client attempts to parse the response as JSON, raising a json.JSONDecodeError that propagates to the _generate_summary method.

  1. Configure an auxiliary model that may return non-JSON responses (e.g., misconfigured endpoint, rate-limited provider, or provider returning HTML error pages)
  • The system should log detailed diagnostics about the error
  • No detailed diagnostics are logged about the provider or error position

Additional Logs / Traceback (optional)

The root cause is that the _generate_summary method in agent/context_compressor.py did not explicitly handle json.JSONDecodeError exceptions. When the auxiliary LLM provider returns a non-JSON response, the JSON parsing fails, but the existing error handling only covered: The JSON decode error was caught by the generic except Exception block, which:

  • Did not log provider details or error position

Root Cause

Root Cause Analysis (optional)

Fix Action

Fixed

Code Example

WARNING: Failed to generate context summary: Expecting value: line 631 column 1 (char 3465)
WARNING: Failed to generate context summary: Expecting value: line 823 column 1 (char 4521)

---

Debug report uploaded:
  Report       https://paste.rs/qeLV4
  agent.log    https://dpaste.com/3UXBRZUPF
  gateway.log  https://dpaste.com/2KX4JLVCZ

---
RAW_BUFFERClick to expand / collapse

Bug Description

The context compression system fails when attempting to generate summaries, resulting in warnings like:

WARNING: Failed to generate context summary: Expecting value: line 631 column 1 (char 3465)
WARNING: Failed to generate context summary: Expecting value: line 823 column 1 (char 4521)

This issue occurs when the auxiliary LLM provider returns a non-JSON response (plain text, HTML error page, or malformed JSON) instead of a valid JSON response. The OpenAI-compatible client attempts to parse the response as JSON, raising a json.JSONDecodeError that propagates to the _generate_summary method.

Steps to Reproduce

  1. Configure an auxiliary model that may return non-JSON responses (e.g., misconfigured endpoint, rate-limited provider, or provider returning HTML error pages)
  2. Run a conversation long enough to trigger context compression
  3. Observe the warning messages in the logs
  4. Note that the compression fails and middle conversation turns are dropped without a summary

Expected Behavior

  • Context compression should succeed by falling back to the main model when the auxiliary model returns invalid JSON
  • The system should log detailed diagnostics about the error
  • The agent should preserve as much conversational context as possible
  • No data loss should occur due to compression failures

Actual Behavior

  • Context compression fails completely
  • The system enters a 60-second cooldown period
  • Middle conversation turns are dropped without a summary
  • No detailed diagnostics are logged about the provider or error position
  • The agent loses conversational context

Affected Component

Agent Core (conversation loop, context compression, memory)

Messaging Platform (if gateway-related)

No response

Debug Report

Debug report uploaded:
  Report       https://paste.rs/qeLV4
  agent.log    https://dpaste.com/3UXBRZUPF
  gateway.log  https://dpaste.com/2KX4JLVCZ

Operating System

macOs 26.3.1

Python Version

3.14.3

Hermes Version

0.13.0

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

The root cause is that the _generate_summary method in agent/context_compressor.py did not explicitly handle json.JSONDecodeError exceptions. When the auxiliary LLM provider returns a non-JSON response, the JSON parsing fails, but the existing error handling only covered:

  • Model not found errors (404, 503)
  • Timeout errors
  • Transient errors (rate limits, network issues)

The JSON decode error was caught by the generic except Exception block, which:

  • Did not log provider details or error position
  • Did not attempt fallback to the main model
  • Entered a 60-second cooldown period
  • Returned None, causing the middle turns to be dropped

This resulted in context compression failures and potential data loss when providers returned invalid responses.

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

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

hermes - ๐Ÿ’ก(How to fix) Fix [Bug]: Context Compression Failure [2 pull requests]