Skip to content

fix(agent): reset flush cursor after compaction (#43066)#43152

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

fix(agent): reset flush cursor after compaction (#43066)#43152
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-43066

Conversation

@kyssta-exe

Copy link
Copy Markdown
Contributor

Fixes #43066. After context compaction, the session DB flush cursor (_last_flushed_db_idx) could retain a stale offset from the pre-compression history, causing compressed messages to not be written to the new child session. This also fixes merge_text=True in queue-mode busy paths that incorrectly joined separate user messages into a single turn.

@liuhao1024

Copy link
Copy Markdown
Contributor

CI regression: merge_text=True → False breaks Telegram follow-up merging

The test (5) shard is failing on test_recent_telegram_followups_append_in_pending_queue:

assert adapter._pending_messages[session_key].text == "part one\npart two"
AssertionError: assert 'part two' == 'part one\npart two'

The two merge_text=Truemerge_text=False changes in gateway/run.py (around lines 6786 and 6806) are the cause. Rapid sequential Telegram messages were previously merged into "part one\npart two" in the pending queue; with merge_text=False, the second message replaces the first, producing only "part two".

The _last_flushed_db_idx = 0 defensive resets look correct and address the compaction flush cursor issue (#43066). However, the merge_text change is a separate behavioral modification — it affects all platform adapters that use the pending-message queue, not just the compaction code path.

Suggestion: Split the merge_text change into a separate commit/PR with a clear justification for why merging is no longer desired. The _last_flushed_db_idx fix can land independently.

@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/agent Core agent loop, run_agent.py, prompt builder comp/gateway Gateway runner, session dispatch, delivery labels Jun 9, 2026
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/gateway Gateway runner, session dispatch, delivery 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 compaction loses assistant messages and merges user follow-ups

3 participants