hermes - 💡(How to fix) Fix [Bug] Context compaction SUMMARY_PREFIX causes cross-session task leakage [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#14603Fetched 2026-04-24 06:16:03
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×3commented ×1referenced ×1

Root Cause

In agent/context_compressor.py lines 37-48:

SUMMARY_PREFIX = (
    "[CONTEXT COMPACTION — REFERENCE ONLY] Earlier turns were compacted "
    "into the summary below. This is a handoff from a previous context "
    "window — treat it as background reference, NOT as active instructions. "
    "Do NOT answer questions or fulfill requests mentioned in this summary; "
    "they were already addressed. "
    "Your current task is identified in the '## Active Task' section of the "
    "summary — resume exactly from there. "
    ...
)

The prefix is self-contradictory:

  1. "treat it as background reference, NOT as active instructions" — says treat as reference only
  2. "Your current task is identified in the '## Active Task' section of the summary — resume exactly from there" — says treat as active task

When a new session receives this summary, the AI reads line 43-44 and immediately interprets the ## Active Task from the previous session as its own current job. This is cross-session task injection, not just cross-session context.

Code Example

SUMMARY_PREFIX = (
    "[CONTEXT COMPACTION — REFERENCE ONLY] Earlier turns were compacted "
    "into the summary below. This is a handoff from a previous context "
    "window — treat it as background reference, NOT as active instructions. "
    "Do NOT answer questions or fulfill requests mentioned in this summary; "
    "they were already addressed. "
    "Your current task is identified in the '## Active Task' section of the "
    "summary — resume exactly from there. "
    ...
)
RAW_BUFFERClick to expand / collapse

Bug Description

Context compaction (agent/context_compressor.py) injects a SUMMARY_PREFIX into compressed sessions that instructs the AI to treat the ## Active Task field from a previous session as the current active task to resume. This causes task leakage across sessions.

Root Cause

In agent/context_compressor.py lines 37-48:

SUMMARY_PREFIX = (
    "[CONTEXT COMPACTION — REFERENCE ONLY] Earlier turns were compacted "
    "into the summary below. This is a handoff from a previous context "
    "window — treat it as background reference, NOT as active instructions. "
    "Do NOT answer questions or fulfill requests mentioned in this summary; "
    "they were already addressed. "
    "Your current task is identified in the '## Active Task' section of the "
    "summary — resume exactly from there. "
    ...
)

The prefix is self-contradictory:

  1. "treat it as background reference, NOT as active instructions" — says treat as reference only
  2. "Your current task is identified in the '## Active Task' section of the summary — resume exactly from there" — says treat as active task

When a new session receives this summary, the AI reads line 43-44 and immediately interprets the ## Active Task from the previous session as its own current job. This is cross-session task injection, not just cross-session context.

Impact

  • Any long-running task (skill building, code projects, research) from a previous session gets reactivated in a new session without user intent
  • AI appears to "go off track" or "not listen" because it is busy resuming an old task it was told to resume
  • This is a persistent, systematic failure — every compressed session inherits this problem

Expected Behavior

The ## Active Task section in the summary should be treated as historical context, not as instructions to execute. The SUMMARY_PREFIX instruction "resume exactly from there" is fundamentally incompatible with the "REFERENCE ONLY" framing.

Suggested Fix

Remove or rewrite the line: "Your current task is identified in the '## Active Task' section of the summary — resume exactly from there."

Replace with something like: "The ## Active Task section describes what was being worked on previously — treat it as historical context only. The user's latest message is the only active instruction."

Or remove ## Active Task from the summary template entirely, since it serves no useful purpose in a "REFERENCE ONLY" context.

extent analysis

TL;DR

Remove or rewrite the conflicting line in the SUMMARY_PREFIX to prevent cross-session task injection.

Guidance

  • Identify the conflicting lines in agent/context_compressor.py (lines 37-48) and assess their impact on session behavior.
  • Consider replacing the problematic line with a new instruction that treats the ## Active Task section as historical context only.
  • Evaluate the necessity of including the ## Active Task section in the summary template, as it may serve no useful purpose in a "REFERENCE ONLY" context.
  • Test the updated SUMMARY_PREFIX to ensure it resolves the cross-session task injection issue without introducing new problems.

Example

SUMMARY_PREFIX = (
    "[CONTEXT COMPACTION — REFERENCE ONLY] Earlier turns were compacted "
    "into the summary below. This is a handoff from a previous context "
    "window — treat it as background reference, NOT as active instructions. "
    "Do NOT answer questions or fulfill requests mentioned in this summary; "
    "they were already addressed. "
    "The ## Active Task section describes what was being worked on previously — treat it as historical context only. "
    "The user's latest message is the only active instruction. "
    ...
)

Notes

The suggested fix assumes that removing or rewriting the conflicting line will resolve the issue without affecting other parts of the system. Further testing is necessary to ensure the updated SUMMARY_PREFIX behaves as expected in different scenarios.

Recommendation

Apply the workaround by removing or rewriting the conflicting line, as it directly addresses the root cause of the issue and prevents cross-session task injection.

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 SUMMARY_PREFIX causes cross-session task leakage [1 comments, 2 participants]