hermes - 💡(How to fix) Fix Bug: Context Compaction causes old messages to be re-injected as new user input (3rd occurrence) [1 comments, 2 participants]

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…
GitHub stats
NousResearch/hermes-agent#14521Fetched 2026-04-24 06:16:46
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Timeline (top)
labeled ×3commented ×1cross-referenced ×1

During long-running sessions with multiple tool calls, Context Compaction (267 turns were removed to free context space) causes historical messages to be erroneously re-injected as new user input, leading the agent to suddenly execute stale/irrelevant instructions. This has been confirmed to occur 3 times.

Root Cause

Root Cause Hypothesis

Context Compaction's state reconstruction phase has a bug in message deduplication / rehydration. When summary generation fails (Summary generation was unavailable) and old turns are discarded, the compaction logic may be incorrectly promoting residual message units from the removed turns into the active input stream.

Code Example

Summary generation was unavailable. 267 conversation turns were removed to free context space but could not be summarized.
RAW_BUFFERClick to expand / collapse

Summary

During long-running sessions with multiple tool calls, Context Compaction (267 turns were removed to free context space) causes historical messages to be erroneously re-injected as new user input, leading the agent to suddenly execute stale/irrelevant instructions. This has been confirmed to occur 3 times.

Environment

  • Platform: Weixin (Home Channel)
  • Model: kimi-k2.6:cloud
  • Hermes Version: v0.7.0+

Expected Behavior

When context compaction occurs, old messages should remain in history. They must never be surfaced as "new user input" to the agent.

Actual Behavior

After compaction, a historical message (e.g. a MiniMax URL from a previous session) appears in the agent's input stream as a fresh user message. The agent then executes it, derailing the current task.

Reproduction Pattern

  1. Start a long-running session with many tool calls
  2. Eventually trigger Context Compaction: Summary generation was unavailable. N conversation turns were removed...
  3. Agent suddenly receives a phantom message that was part of the removed/compacted history
  4. Agent executes the phantom message, producing irrelevant output

Specific Incident (3rd occurrence, 2026-04-23)

  • Current task: Searching for cattle behavioral datasets on Zenodo
  • Phantom message injected: https://platform.minimaxi.com/user-center/payment/token-plan
  • User confirmed: This URL was never sent by the user during this session
  • Agent impact: Agent navigated to the URL and also attempted to execute an unrelated historical task (the Zenodo supplemental search from a prior session), resulting in a mixed/confused response
  • Compaction log:
    Summary generation was unavailable. 267 conversation turns were removed to free context space but could not be summarized.

Root Cause Hypothesis

Context Compaction's state reconstruction phase has a bug in message deduplication / rehydration. When summary generation fails (Summary generation was unavailable) and old turns are discarded, the compaction logic may be incorrectly promoting residual message units from the removed turns into the active input stream.

Impact

  • 🔴 High severity: Agent executes phantom commands, wasting tokens and derailing user tasks
  • Breaks user trust (now on the 3rd occurrence)
  • Could lead to harmful actions if the phantom message were an execute command

Suggested Fixes

  1. Add source validation during compaction rehydration: verify a message's origin before allowing it into the active input stream
  2. When summary generation fails, fall back to safe mode (discard unrecognizable units rather than guess)
  3. Physically isolate user-input queue from historical context storage so compaction can never bridge them

Additional Context

  • Previously flagged in agent memory as a recurring issue: "用户批评我多次出现上下文混乱('这不是第一次了')"
  • Two prior instances occurred under similar long-session conditions (details to be added if reproducible)

extent analysis

TL;DR

Implement source validation during compaction rehydration to prevent historical messages from being re-injected as new user input.

Guidance

  • Verify the root cause hypothesis by analyzing the compaction logic and message deduplication/rehydration process to confirm the bug.
  • Consider implementing a temporary workaround by discarding unrecognizable units when summary generation fails, as suggested in the "safe mode" approach.
  • Physically isolating the user-input queue from historical context storage can help prevent compaction from bridging them and causing the issue.
  • Review the agent's memory and prior instances to gather more information and identify patterns that may help in resolving the issue.

Example

No code snippet is provided as the issue does not contain sufficient technical details to create a minimal example.

Notes

The suggested fixes and guidance are based on the provided root cause hypothesis and may need to be adjusted if the actual root cause is different. Additionally, the issue's high severity and potential for harmful actions emphasize the need for a thorough and careful approach to resolving the problem.

Recommendation

Apply workaround: Implement source validation during compaction rehydration to prevent historical messages from being re-injected as new user input, as this approach directly addresses the suspected root cause and can help mitigate the issue until a more permanent fix is available.

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