fix: sync btw messages to in-memory caches to preserve conversation context by wgqqqqq · Pull Request #187 · GCWing/BitFun

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