← All questions
RAGHard· Context Management· Query Rewriting

The team wants to concatenate the last N turns into the...

A fixed window approach is fundamentally flawed because it ignores the semantic structure of a conversation. Instead of a fixed N, you should implement a switch classifier to detect topic boundaries and use a summary to compress the context that needs to persist. Recency weighting is insufficient because it acts as a soft detector that cannot express the hard boundaries required when a user shifts topics.

Code playground (Python)