Skip to content

fix(agent): flush un-persisted messages before session rotation (#47202)#47215

Closed
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-47202
Closed

fix(agent): flush un-persisted messages before session rotation (#47202)#47215
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-47202

Conversation

@kyssta-exe

Copy link
Copy Markdown
Contributor

Fixes #47202. compress_context() rotates the session_id (end_session -> create_session) mid-turn when auto-compress triggers, but never called _flush_messages_to_session_db() first. Messages generated during the current turn that hadn't been persisted to state.db were silently lost.

The same bug existed in cli.py:new_session() (the /new command). Both paths now flush un-persisted messages before ending the old session, preventing data loss on session rotation.

…Research#47202)

compress_context() rotates the session (end_session -> create_session)
mid-turn when auto-compress triggers, but never called
_flush_messages_to_session_db() first. Messages generated during the
current turn that hadn't been persisted to state.db were silently lost.

The same bug existed in cli.py:new_session() (/new command). Both paths
now flush un-persisted messages before ending the old session.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent loop, run_agent.py, prompt builder comp/cli CLI entry point, hermes_cli/, setup wizard P1 High — major feature broken, no workaround duplicate This issue or pull request already exists labels Jun 16, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #47204 (filed earlier, ~11:35 UTC). Both touch agent/conversation_compression.py + cli.py with the identical flush-before-rotate approach covering compression AND the /new CLI path. Related same-goal-different-mechanism competitors: #46587, #41057.

@teknium1

Copy link
Copy Markdown
Contributor

Merged via #48584 — your commit was cherry-picked onto current main with your authorship preserved in git log (commit 81ff916). Fixes the flush-before-rotate data loss for both #47202 and #46567. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Context compression silently loses unflushed messages (end_session without flush)

3 participants