hermes - ✅(Solved) Fix [Bug]: Manual Session Compression Causes System Prompt Duplication (102% Size Increase) [2 pull requests, 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#15281Fetched 2026-04-25 06:23:14
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×3cross-referenced ×2commented ×1

Error Message

Additional Logs / Traceback (optional)

Root Cause

Root Cause Analysis (optional)

Fix Action

Fixed

PR fix notes

PR #15304: fix(cli): pass None as system_message in manual /compress to prevent system prompt duplication

Description (problem / solution / changelog)

Problem

Manual /compress caused system prompt to double in size (+102%) because _manual_compress() passed self.agent._cached_system_prompt as system_message to _compress_context(). _build_system_prompt(system_message) then appended it to prompt_parts which already contained the agent identity block — resulting in the identity appearing twice.

Fix

Pass None instead of _cached_system_prompt. _build_system_prompt(None) rebuilds the system prompt correctly from scratch without appending a pre-built prompt on top of the identity layers.

Fixes #15281

Changed files

  • cli.py (modified, +7/-1)

PR #15452: fix(cli): pass None as system_message in manual /compress to prevent duplication (#15281)

Description (problem / solution / changelog)

Summary

  • _manual_compress was passing _cached_system_prompt to _compress_context, but _build_system_prompt already assembles the identity block into prompt_parts
  • The redundant system_message caused the identity to appear twice in the compressed output
  • Pass None so _compress_context rebuilds the prompt from scratch

Test plan

  • test_compress_context_receives_none_system_message — verifies second positional arg to _compress_context is None
  • test_compress_context_receives_focus_topic — verifies /compress <topic> forwards the focus topic
  • 2/2 tests pass

Fixes #15281. Supersedes #15304.

Changed files

  • cli.py (modified, +7/-1)
  • tests/cli/test_manual_compress_system_prompt.py (added, +90/-0)

Code Example

Report       https://paste.rs/JoS7X
  agent.log    https://paste.rs/eBZD3
  gateway.log  https://paste.rs/4lssL

---
RAW_BUFFERClick to expand / collapse

Bug Description

Manual session compression (/compress) causes system prompt to double in size (20,957 → 42,303 chars, +102%) due to duplicate agent identity definitions being concatenated.

Steps to Reproduce

  1. Run session with 300+ messages

  2. Trigger manual compression (/compress)

  3. Check database: bash sqlite3 ~/.hermes/state.db "SELECT id, length(system_prompt) FROM sessions ORDER BY started_at DESC LIMIT 2;"

  4. Verify duplication: bash sqlite3 ~/.hermes/state.db "SELECT system_prompt FROM sessions WHERE id = 'new_session_id';" | grep -c "You are Hermes Agent" Returns: 2 (should be 1)

Expected Behavior

MetricOld SessionNew SessionChange
System Prompt Size20,957 chars42,303 chars+102%
"You are Hermes Agent" count12Duplicate
Compression SummaryN/ANot foundMissing

Actual Behavior

MetricOld SessionNew SessionChange
System Prompt Size20,957 chars42,303 chars+102%
"You are Hermes Agent" count12Duplicate
Compression SummaryN/ANot foundMissing

Affected Component

Other

Messaging Platform (if gateway-related)

No response

Debug Report

Report       https://paste.rs/JoS7X
  agent.log    https://paste.rs/eBZD3
  gateway.log  https://paste.rs/4lssL

Operating System

macOS 26.4.1

Python Version

3.11.15

Hermes Version

v0.11.0 (2026.4.23)

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

No response

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

extent analysis

TL;DR

The issue can be addressed by modifying the manual session compression logic to prevent duplicate agent identity definitions from being concatenated, potentially by updating the compression algorithm or the database query that handles session data.

Guidance

  • Review the manual compression logic to identify where the duplication of agent identity definitions occurs and consider updating the algorithm to remove duplicates.
  • Verify the issue by running the provided SQLite queries to check the system prompt size and the count of "You are Hermes Agent" before and after triggering manual compression.
  • Investigate the agent.log and gateway.log files provided in the debug report for any relevant error messages or clues that could help in identifying the root cause.
  • Consider modifying the database query that handles session data to prevent the concatenation of duplicate agent identity definitions during compression.

Example

No specific code snippet can be provided without more information on the compression logic, but an example of how to remove duplicates from a string in Python could be:

def remove_duplicates(input_string, duplicate_string):
    return input_string.replace(duplicate_string, "").strip()

# Example usage:
system_prompt = "You are Hermes Agent You are Hermes Agent"
cleaned_prompt = remove_duplicates(system_prompt, "You are Hermes Agent")
print(cleaned_prompt)  # Output: "" (empty string, as the entire string was the duplicate)

However, this is highly speculative and actual implementation details are needed for a precise solution.

Notes

The provided information suggests that the issue is related to the manual session compression feature, but without access to the compression logic or more detailed logs, it's challenging to provide a definitive fix. The solution may involve updating the compression algorithm, modifying the database queries, or adjusting how session data is handled.

Recommendation

Apply a workaround by manually removing the duplicate agent identity definitions from the system prompt after compression, until a more permanent fix can be implemented. This is because the root cause seems to be related to the compression logic, which

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 - ✅(Solved) Fix [Bug]: Manual Session Compression Causes System Prompt Duplication (102% Size Increase) [2 pull requests, 1 comments, 2 participants]