DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(mastery): explain failed source repair in the session language (#1902)
Bingxi Zhao (Frank)0aa12fdfb6ba
diff --git a/deeptutor/capabilities/mastery/prompts/en/mastery_loop.yaml b/deeptutor/capabilities/mastery/prompts/en/mastery_loop.yamlindex 0a9369e68..2a6f24d6d 100644--- a/deeptutor/capabilities/mastery/prompts/en/mastery_loop.yaml+++ b/deeptutor/capabilities/mastery/prompts/en/mastery_loop.yaml@@ -13,6 +13,9 @@ preparation:checking_pages: Checking original pages and figuresrepairing: Resolving a missing or unreadable detail with one targeted retry+ incomplete_sources: Source evidence is incomplete.+ repair_incomplete: "Source evidence remains incomplete after one targeted retry: "+general: |-You are the learner's one-on-one mastery tutor.They work through an outline of objectives, each behind a HARD mastery gate: an objective counts as mastered once its gate clears, and you do not move on until it does.diff --git a/deeptutor/capabilities/mastery/prompts/zh/mastery_loop.yaml b/deeptutor/capabilities/mastery/prompts/zh/mastery_loop.yamlindex d9eb9edf7..319e74eaa 100644--- a/deeptutor/capabilities/mastery/prompts/zh/mastery_loop.yaml+++ b/deeptutor/capabilities/mastery/prompts/zh/mastery_loop.yaml@@ -12,6 +12,9 @@ preparation:checking_pages: 正在检查原始页面和图表repairing: 正在对缺失或难以辨认的细节进行一次针对性重试+ incomplete_sources: 来源证据不完整。+ repair_incomplete: "经过一次针对性重试,来源证据仍不完整:"+general: |-你是学习者的一对一掌握式导师。他沿着一份精通大纲前进,大纲里每个知识点后面都有一道硬性掌握门槛:门槛过了,这个知识点才算掌握;没过,就不推进到下一个。diff --git a/deeptutor/learning/lesson_evidence.py b/deeptutor/learning/lesson_evidence.pyindex b216d3181..1fe8de725 100644--- a/deeptutor/learning/lesson_evidence.py+++ b/deeptutor/learning/lesson_evidence.py@@ -490,7 +490,7 @@ def _repair_request(feedback: dict[str, Any]) -> dict[str, Any]:or not repair["reason"].strip()):raise LessonUnavailable(- "A hiányhoz nincs konkrét, biztonságos javítási javaslat. Szűkítsd a témát vagy ellenőrizd a forrást."+ "No specific, safe repair is available for this gap. Narrow the objective or check the source.")return {**repair, "reason": repair["reason"].strip()[:500]}@@ -504,7 +504,7 @@ def _repair_page(raise LessonUnavailable("Invalid repair source index.")if len(sources) >= 6:raise LessonUnavailable(- "A célzott javítás túllépné a hatoldalas keretet. Szűkítsd a tanulási célt."+ "The targeted repair would exceed the six-page limit. Narrow the learning objective.")original = sources[start + local]ref = SourceRef.model_validate(original["ref"])@@ -964,14 +964,16 @@ async def prepare_lesson(complete = Truebreakfeedback = feedback or ranking- gap = str(feedback.get("limitations") or feedback.get("missing") or "Hiányos forrás.")[- :500- ]+ gap = str(+ feedback.get("limitations")+ or feedback.get("missing")+ or prompt_text(prompts, ("preparation", "incomplete_sources"))+ )[:500]if attempt:if verified_sources:breakraise LessonUnavailable(- "Az egyszeri célzott javítás után is hiányos a forrás: " + gap+ prompt_text(prompts, ("preparation", "repair_incomplete")) + gap)if feedback.get("repair") is None and verified_sources:breakdiff --git a/tests/services/rag/test_mastery_source_pages.py b/tests/services/rag/test_mastery_source_pages.pyindex 6f75db189..ec2d6fbb6 100644--- a/tests/services/rag/test_mastery_source_pages.py+++ b/tests/services/rag/test_mastery_source_pages.py@@ -1136,7 +1136,10 @@ def test_repair_retains_useful_pages_selected_near_end_of_initial_candidates():assert {6, 4, 1, 8, 20}.issubset({c["ref"]["page_index"] for c in selected})-def test_repair_never_loops_or_publishes_failed_evidence(material, monkeypatch):+ "language, message", [("en", "one targeted retry"), ("zh", "一次针对性重试")]+)+def test_repair_never_loops_or_publishes_failed_evidence(material, monkeypatch, language, message):failure = {"usable": False,"limitations": "Still unreadable",@@ -1148,8 +1151,10 @@ def test_repair_never_loops_or_publishes_failed_evidence(material, monkeypatch):},}calls = _install_preparation(material, monkeypatch, vision_responses=[failure, failure])- with pytest.raises(lessons.LessonUnavailable, match="egyszeri"):- asyncio.run(lessons.prepare_lesson(material.store, "path", "kp", material.config))+ with pytest.raises(lessons.LessonUnavailable, match=message):+ asyncio.run(+ lessons.prepare_lesson(material.store, "path", "kp", material.config, language=language)+ )assert len(calls) == 4assert not material.store.load("path").lesson_evidence