hermes - 💡(How to fix) Fix [BUG] Context compaction causes duplicate responses after compression [1 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#11475Fetched 2026-04-18 06:00:51
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants

Root Cause

When context is compacted, old messages are replaced with a summary. The system injects an "Active Task" field pointing to the last task being worked on. However, this task may be hours old.

The agent's instruction says "Respond ONLY to the latest user message" but the summary's "Active Task" appears as the latest content, causing the agent to continue working on tasks from hours ago as if they were new.

Code Example

# After compaction, inject:
COMPACTED_BOUNDARY = True
LAST_PROCESSED_TURN = {last_turn_id}
RAW_BUFFERClick to expand / collapse

Bug Description

After context compaction, the agent repeats responses to old messages that were already processed hours ago.

Root Cause

When context is compacted, old messages are replaced with a summary. The system injects an "Active Task" field pointing to the last task being worked on. However, this task may be hours old.

The agent's instruction says "Respond ONLY to the latest user message" but the summary's "Active Task" appears as the latest content, causing the agent to continue working on tasks from hours ago as if they were new.

Expected Behavior

After compaction, the agent should only respond to user messages that arrive AFTER the compaction. Old tasks in the summary should be marked as "already completed" and not re-processed.

Proposed Fix

Add a compaction boundary flag in run_agent.py:

# After compaction, inject:
COMPACTED_BOUNDARY = True
LAST_PROCESSED_TURN = {last_turn_id}

The agent prompt should be updated to:

  • If COMPACTED_BOUNDARY == True, ignore summary content and only respond to messages arriving after the compaction point.
  • Treat all summary content as "already processed."

extent analysis

TL;DR

Update the agent's logic to ignore summary content and only respond to new messages after the compaction point by adding a COMPACTED_BOUNDARY flag and checking it in the agent prompt.

Guidance

  • Add a COMPACTED_BOUNDARY flag in run_agent.py and set it to True after compaction, along with the LAST_PROCESSED_TURN ID.
  • Update the agent prompt to check the COMPACTED_BOUNDARY flag and ignore summary content if it's True.
  • Ensure the agent only responds to messages with a turn ID greater than the LAST_PROCESSED_TURN ID when COMPACTED_BOUNDARY is True.
  • Verify that old tasks in the summary are marked as "already completed" and not re-processed after compaction.

Example

if COMPACTED_BOUNDARY:
    # Ignore summary content and only respond to new messages
    if message_turn_id > LAST_PROCESSED_TURN:
        # Respond to the new message
        pass
    else:
        # Treat the message as already processed
        pass

Notes

This fix assumes that the LAST_PROCESSED_TURN ID is correctly updated after compaction and that the agent's prompt is properly updated to check the COMPACTED_BOUNDARY flag.

Recommendation

Apply the proposed workaround by adding the COMPACTED_BOUNDARY flag and updating the agent prompt, as this directly addresses the root cause of the issue and ensures the agent only responds to new messages after compaction.

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 compaction causes duplicate responses after compression [1 participants]