DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
Merge pull request #1834 from dajiaohuang/fix/pocketbase-message-cursors
Bingxi Zhao3de64fdd02f8
diff --cc deeptutor/services/session/context_builder.pyindex 624040944,845e4693a..51b1655c8--- a/deeptutor/services/session/context_builder.py+++ b/deeptutor/services/session/context_builder.py@@@ -570,21 -533,23 +570,27 @@@ class ContextBuilder# After an edit-branch switch it may point into a sibling branch — the# stored summary would then carry content this branch never saw.# Discard both and rebuild from this branch's own messages.- if summary_up_to_msg_id > 0 and not any(- int(item.get("id", 0) or 0) == summary_up_to_msg_id for item in messages- ):+ summary_position = next(+ (+ index+ for index, item in enumerate(messages)+ if summary_up_to_msg_id and str(item.get("id")) == str(summary_up_to_msg_id)+ ),+ None,+ )+ if summary_up_to_msg_id and summary_position is None:stored_summary = ""summary_up_to_msg_id = 0- unsummarized = [- item for item in messages if int(item.get("id", 0) or 0) > summary_up_to_msg_id- ]+ unsummarized = (+ messages[summary_position + 1 :] if summary_position is not None else messages+ )+ binding = getattr(llm_config, "binding", None)+ route = (+ {"provider": binding, "model": llm_config.model} if isinstance(binding, str) else None+ )current_history = self._build_history(stored_summary, unsummarized)- current_tokens = self._model_tokens(unsummarized, stored_summary)+ current_tokens = self._model_tokens(unsummarized, stored_summary, route)previous_model_turn = next((record for row in reversed(messages) if (record := model_turn(row)) is not None),None,