DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(partners): only start Partner authoring on an actual creation request
Mohammad Hijjawi4f5db49b343c
diff --git a/deeptutor/capabilities/partner_authoring/binding.py b/deeptutor/capabilities/partner_authoring/binding.pyindex 17f7bb0c1..bad8c87a1 100644--- a/deeptutor/capabilities/partner_authoring/binding.py+++ b/deeptutor/capabilities/partner_authoring/binding.py@@ -8,14 +8,26 @@ from deeptutor.core.context import UnifiedContextPARTNER_AUTHORING_CAPABILITY_NAME = "partner_authoring"-_ACTION = re.compile(- r"(创建|新建|生成|设计|定制|做一个|来一个|来个|想要|需要|帮我做|帮我建|加一个)"- r"|(\bcreate\b|\bmake\b|\bbuild\b|\bdesign\b|\bgenerate\b|\bwant\b|\bneed\b|\badd\b)",- re.IGNORECASE,+# The action has to lead into the Partner object within one clause. Matching the two words+# anywhere in the message fired on turns that only mention a Partner ("I want to file an issue+# about the Partner bug"), and finish_instruction then forces a draft the user never asked for.+_ZH_ACTION = (+ r"(?:创建|新建|生成|设计|定制|帮我做|帮我建|做一个|来一个|来个|加一个"+ r"|(?:想要|需要)(?:一个|一位|个|位))"+)+_ZH_OBJECT = r"(?:partner|伙伴|学习搭子|陪伴者|陪练|助教|导师|教练|学伴|智能体|角色)"+# Stops at clause punctuation and at words that make the object a topic rather than the target.+_ZH_GAP = r"(?:(?!关于|有关|提到|讨论)[^。!?!?;;,,、\n]){0,16}?"+_EN_ACTION = (+ r"(?:\b(?:create|make|build|design|generate|add|set\s+up)\b(?:\s+(?:me|us))?"+ r"|\b(?:want|need)\b)")-_OBJECT = re.compile(- r"(partner|伙伴|学习搭子|陪伴者|陪练|助教|导师|教练|学伴|智能体|角色)"- r"|(\bcompanion\b|\btutor\b|\bmentor\b|\bcoach\b|\bstudy buddy\b)",+_EN_DETERMINER = r"\s+(?:a|an|another|one|my\s+own|our\s+own|a\s+new|new)\b"+_EN_GAP = r"(?:\s+(?!(?:about|with|for|of|from|in|on|to|that|which)\b)[\w'-]+){0,3}?"+_EN_OBJECT = r"\s+(?:partners?|companions?|tutors?|mentors?|coach(?:es)?|study\s+budd(?:y|ies))\b"++_AUTHORING_REQUEST = re.compile(+ rf"{_ZH_ACTION}{_ZH_GAP}{_ZH_OBJECT}|{_EN_ACTION}{_EN_DETERMINER}{_EN_GAP}{_EN_OBJECT}",re.IGNORECASE,)@@ -29,7 +41,7 @@ def is_partner_authoring_turn(context: UnifiedContext) -> bool:if context.active_capability == PARTNER_AUTHORING_CAPABILITY_NAME:return Truetext = str(context.user_message or "")- return bool(_ACTION.search(text) and _OBJECT.search(text))+ return _AUTHORING_REQUEST.search(text) is not None__all__ = ["PARTNER_AUTHORING_CAPABILITY_NAME", "is_partner_authoring_turn"]diff --git a/tests/capabilities/test_partner_authoring_capability.py b/tests/capabilities/test_partner_authoring_capability.pyindex d4f4615a3..c25ed42ef 100644--- a/tests/capabilities/test_partner_authoring_capability.py+++ b/tests/capabilities/test_partner_authoring_capability.py@@ -26,6 +26,38 @@ def test_partner_authoring_activation_requires_action_and_partner_object() -> Noassert not is_partner_authoring_turn(partner_context)+ "message",+ [+ "Create a partner that quizzes me on French verbs",+ "I want a patient math tutor",+ "Can you make me a strict coach?",+ "Set up a new study buddy for physics",+ "我想要一个数学导师",+ "来个学习搭子",+ ],+)+def test_partner_authoring_activates_on_a_creation_request(message: str) -> None:+ assert is_partner_authoring_turn(_context(message))+++ "message",+ [+ "I want to file an issue about the Partner bug",+ "I want to report that Partner creation keeps triggering",+ "I need help understanding my tutor's feedback",+ "Make sure my tutor sees this",+ "Why can a flash-tier model answer well? The release notes mention Partner channels.",+ "我想提交一个关于伙伴功能的 bug",+ "生成的回答里提到了伙伴",+ "我需要解释一下,为什么会触发伙伴创建",+ ],+)+def test_partner_authoring_ignores_turns_that_only_mention_a_partner(message: str) -> None:+ assert not is_partner_authoring_turn(_context(message))++def test_capability_forces_a_draft_before_finishing() -> None:capability = PartnerAuthoringCapability()context = _context("创建一个伙伴")