DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix: restore recency weighting in compute_mastery (#618)
whm5d7647002ee2
diff --git a/deeptutor/learning/mastery.py b/deeptutor/learning/mastery.pyindex f0352e818..dcacd90c1 100644--- a/deeptutor/learning/mastery.py+++ b/deeptutor/learning/mastery.py@@ -31,7 +31,7 @@ def compute_mastery(correctness: list[bool]) -> float:return 0.0recent = correctness[-len(_RECENCY_WEIGHTS) :]weights = _RECENCY_WEIGHTS[-len(recent) :]- score = sum(w * (1.0 if c else 0.0) for w, c in zip(recent, weights, strict=True)) / sum(+ score = sum(w * (1.0 if c else 0.0) for c, w in zip(recent, weights, strict=True)) / sum(weights)return min(score, _CONFIDENCE_CAP.get(len(recent), 1.0))diff --git a/deeptutor/learning/tests/test_guided_mastery_updates.py b/deeptutor/learning/tests/test_guided_mastery_updates.pyindex 287444952..acf763578 100644--- a/deeptutor/learning/tests/test_guided_mastery_updates.py+++ b/deeptutor/learning/tests/test_guided_mastery_updates.py@@ -69,6 +69,18 @@ def test_compute_mastery_partial_correctness_scales():assert one_of_five < two_of_five < three_of_five+def test_compute_mastery_weighs_recent_attempts_more_heavily():+ """Regression test for #618: recency weighting must actually distinguish+ a recovering history from a declining one, even with the same correct+ count. A miss-then-two-hits history should score higher than a+ two-hits-then-miss history."""+ recovering = compute_mastery([False, True, True])+ declining = compute_mastery([True, True, False])+ assert recovering > declining+ assert recovering == pytest.approx(0.696, abs=1e-3)+ assert declining == pytest.approx(0.643, abs=1e-3)++# ── grade_and_record: the unified post-answer pipeline ─────────────────────