Bug Description
/clear and /new call new_session() which resets conversation_history, session_id, token counters, and the todo store — but two pieces of state survive and pollute the new session:
-
ContextCompressor._previous_summary is never cleared by reset_session_state(). If compression ran in the previous session, the old summary persists and seeds the next iterative compression in the new session (context_compressor.py line 252–257). This means context from a prior conversation leaks into the new session's compression.
-
_user_turn_count is initialized to 0 in __init__ (line 1065) but never reset in reset_session_state(). After /clear, the counter keeps accumulating, which affects flush_min_turns guard behavior in the new session.
Steps to Reproduce
- Start a hermes session, have a long conversation that triggers context compression
- Type
/clear or /new
- Start a new conversation on a completely different topic
- When compression triggers again, observe that the summary references content from the previous session
Expected Behavior
/clear and /new should produce a fully clean slate. The compression summary and turn counter should be reset alongside everything else.
Actual Behavior
_previous_summary from the old session survives and is used to seed the next compression, causing cross-session context pollution.
Root Cause Analysis
In run_agent.py, reset_session_state() (line ~1119–1125) resets:
compression_count
_total_prompt_tokens / _total_completion_tokens
_context_probed
_last_flushed_db_idx
_todo_store
But does NOT reset:
self._previous_summary (or the compressor's _previous_summary)
self._user_turn_count
Proposed Fix
Add to reset_session_state():
self._user_turn_count = 0
if hasattr(self, 'context_compressor') and self.context_compressor:
self.context_compressor._previous_summary = None
Or alternatively, re-instantiate the ContextCompressor in reset_session_state().
Affected Component
Agent Core (conversation loop, context compression, memory)
Operating System
Ubuntu 24.04
Python Version
3.12
Hermes Version
0.4.0
Are you willing to submit a PR for this?
Bug Description
/clearand/newcallnew_session()which resetsconversation_history,session_id, token counters, and the todo store — but two pieces of state survive and pollute the new session:ContextCompressor._previous_summaryis never cleared byreset_session_state(). If compression ran in the previous session, the old summary persists and seeds the next iterative compression in the new session (context_compressor.pyline 252–257). This means context from a prior conversation leaks into the new session's compression._user_turn_countis initialized to0in__init__(line 1065) but never reset inreset_session_state(). After/clear, the counter keeps accumulating, which affectsflush_min_turnsguard behavior in the new session.Steps to Reproduce
/clearor/newExpected Behavior
/clearand/newshould produce a fully clean slate. The compression summary and turn counter should be reset alongside everything else.Actual Behavior
_previous_summaryfrom the old session survives and is used to seed the next compression, causing cross-session context pollution.Root Cause Analysis
In
run_agent.py,reset_session_state()(line ~1119–1125) resets:compression_count_total_prompt_tokens/_total_completion_tokens_context_probed_last_flushed_db_idx_todo_storeBut does NOT reset:
self._previous_summary(or the compressor's_previous_summary)self._user_turn_countProposed Fix
Add to
reset_session_state():Or alternatively, re-instantiate the
ContextCompressorinreset_session_state().Affected Component
Agent Core (conversation loop, context compression, memory)
Operating System
Ubuntu 24.04
Python Version
3.12
Hermes Version
0.4.0
Are you willing to submit a PR for this?