Skip to content

fix: sync btw messages to in-memory caches to preserve conversation context#187

Merged
GCWing merged 1 commit intoGCWing:mainfrom
wgqqqqq:fix-btw-context-loss
Mar 19, 2026
Merged

fix: sync btw messages to in-memory caches to preserve conversation context#187
GCWing merged 1 commit intoGCWing:mainfrom
wgqqqqq:fix-btw-context-loss

Conversation

@wgqqqqq
Copy link
Collaborator

@wgqqqqq wgqqqqq commented Mar 18, 2026

Fix: BTW continue flow loses previous conversation context

Problem

When using the /btw conversation flow and then asking a follow-up question, the assistant behaves as if the previous conversation does not exist. The follow-up appears to start from a fresh context instead of continuing the existing conversation.

Root Cause

In persist_btw_turn method (session_manager.rs), when a /btw conversation completes, although the DialogTurnData was saved to persistence layer, the user message and assistant response were not synced to the in-memory caches (MessageHistoryManager and CompressionManager).

When users send follow-up messages in the btw session, get_context_messages couldn't retrieve previous conversation context, making the conversation appear as a new empty session.

Fix

After persisting the turn to disk, sync the user message and assistant response to both memory caches.

Testing

  • cargo check -p bitfun-core passes

Fixes #182

When a /btw side question completes, persist_btw_turn was only saving
DialogTurnData to disk but not syncing messages to MessageHistoryManager
and CompressionManager in-memory caches.

This caused subsequent messages in btw sessions to lose conversation
context, making the session appear empty.

Now we add the user and assistant messages to both memory caches
after persisting, ensuring context is available for follow-up questions.

Fixes GCWing#182
@GCWing GCWing merged commit 49c7a36 into GCWing:main Mar 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/btw continue flow loses previous conversation context

2 participants