diff --git a/semantic_router/schema.py b/semantic_router/schema.py index 1f4bc5f0c9bc2e6b589a2e1807ea55871b51a476..129d154a65e9d7dcbf7c3e37002d65d1c99f3f92 100644 --- a/semantic_router/schema.py +++ b/semantic_router/schema.py @@ -121,8 +121,9 @@ class Conversation(BaseModel): # Use the splitter to split the documents new_topics = self.splitter(docs) - # Check if the first new topic includes any of the new messages - if any(message in new_topics[0].docs for message in docs[-len(unclustered_messages):]): + # Check if the first new topic includes the first new message. + # This means that the first new message shares the same topic as the last old message to have been assigned a topic. + if docs[-len(unclustered_messages)] in new_topics[0].docs: start = self.topics[-1][0] else: start = len(self.topics) + 1