Skip to content

[Bug]: Manual Session Compression Causes System Prompt Duplication (102% Size Increase) #15281

@laoli-no1

Description

@laoli-no1

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

Metric Old Session New Session Change
System Prompt Size 20,957 chars 42,303 chars +102%
"You are Hermes Agent" count 1 2 Duplicate
Compression Summary N/A Not found Missing

Actual Behavior

Metric Old Session New Session Change
System Prompt Size 20,957 chars 42,303 chars +102%
"You are Hermes Agent" count 1 2 Duplicate
Compression Summary N/A Not found Missing

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — major feature broken, no workaroundcomp/agentCore agent loop, run_agent.py, prompt buildertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions