17 Commits

Author SHA1 Message Date
Benjamin Schwing
b7dd96d453 fix(mastery): grade concept objectives within covered and own scope (#2363, #2364) (#2366)
* fix(mastery): grade within the objective's covered and own scope

- Reuse the preserved objective-scoped packet for an objective request
  after a focus preparation replaced the live slot, and do not rebuild
  an incomplete objective packet whose fingerprints are unchanged (#2363).
- mastery_assess grades a concept/design explanation against the covered
  facets of an incomplete objective packet, records that scope, and
  returns a structured coverage_gap result instead of a bare refusal.
- Tell the learner when an answer was not recorded or was graded only
  against the covered part.
- Give the judge sibling objectives as out of scope and return the
  single missing element with a next_step to ask for exactly it (#2364).

* test(mastery): cover the focus-only assessment deadlock from #2905

A complete focus-scoped packet with no assessment slot gets a structured
coverage_gap on every repeated mastery_assess, with no judge call and no
recorded evidence. One objective preparation then grades the retained
explanation together with the next reply.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>

* fix(mastery): make the missing-element step the assess instruction

Since dev added a generic instruction to every final mastery_assess
payload, a non-passing verdict carried two competing moves: next_step
asked for exactly the named missing element (#2364) and instruction
asked the learner to explain the objective again. While the gate is not
cleared, the targeted step is now also the instruction, and it says to
record the reply with mastery_assess.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>

* fix(mastery): say when an unclear explanation is kept for grading

A non-final verdict in a session keeps the explanation and grades it
together with the follow-up, so the generic "not recorded, progress
unchanged" notice misled the learner into repeating the whole answer.
Add an assessment_needs_clarification notice (en/zh) for that case; an
explanation outside a session keeps the not_recorded notice.

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>

* fix(mastery): preserve the missing assessment element on replay

---------

Signed-off-by: Benjamin Schwing <63053132+BenjiAvH@users.noreply.github.com>
Co-authored-by: Qiuner <wdst3635@163.com>
2026-11-30 06:32:56 -03:00
Bingxi Zhao (Frank)
e81f9c866d fix(mastery): save a standalone reference answer for qualitative practice 2026-11-15 01:00:14 +08:00
Bingxi Zhao (Frank)
be4f36c166 fix(mastery): normalize option arrays and clarify grading evidence
Local dev repairs for #2687, #2691. Regression checks cover reported symptoms and compatibility boundaries.
2026-11-15 00:44:09 +08:00
Bingxi Zhao (Frank)
69a9ad9cc0 Merge PR #2608: fix: give lesson preparation and grading room for reasoning models 2026-11-14 22:58:03 +08:00
Benjamin Schwing
2ba6b5d75c fix(mastery): keep an issued question gradable after its KB is re-indexed (#2650)
A pending quiz card stores the source snapshot it was verified against,
including a fingerprint of the whole published KB index. Adding any
document to that KB changed the fingerprint, so every grade failed with
"Prepare the lesson again" - which refreshes only the lesson packet,
never the card - and the learner's answer could not be recorded.

An issued question is now bound to the pages it cites: when the index
changed but each cited page (KB, document, page, source digest) is still
published unchanged, the question validates and is graded. If a cited
page did change, the error says so and names the recovery tools.
Lesson packets and question issuance keep the strict whole-index check;
objective, answer-key and scope gates are unchanged.
2026-11-12 16:49:56 +00:00
elvisgraho
3bfdb0fc29 fix: give lesson preparation and grading room for reasoning models
Source selection asks for at most 1800 output tokens and grading for 2200.
Reasoning models count hidden reasoning against max_tokens. On a real course
page set, nvidia/nemotron-3.5-super-vl (OpenRouter) stopped with
finish_reason=length in 5 of 5 runs after spending all 1800 tokens on
reasoning, so the reply had no JSON and preparation failed with "invalid
source-selection response". The #2367 retry lowers reasoning_effort to "low",
which this model does not honour: on a small probe it reasoned more, not less,
and in the app the retry failed the same way.

Raise both caps to 8192. Replaying the same request with an 8000-token cap
finished in 3 of 3 runs (2.4k-4.1k reasoning tokens), and full preparation
then completed for 4 of 4 objectives. max_tokens is a ceiling, so models that
answer briefly are unaffected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 21:04:06 +01:00
Bingxi Zhao (Frank)
8bda305a43 Merge #2415 from maxsheng215-cyber 2026-11-06 01:56:26 +08:00
我也有友人账
7b5390ffe0 fix: retry mismatched mastery assessment quotes 2026-11-03 14:46:55 -08:00
Mehedi Hasan
93fa314ce7 fix(learning): read lesson JSON from reasoning-model replies
Prepare Lesson parsed the model reply with json.loads after stripping
only a leading code fence. Reasoning models add <think> blocks or a
prose preface, and at high effort can spend the 1800-token budget on
hidden reasoning, so every attempt failed as an invalid source-selection
response. Assessment requests share the same parser.

Strip closed <think>/<thinking> blocks, treat a reply that still opens
with reasoning as unanswered, and scan for the first JSON object with
JSONDecoder.raw_decode. Truncated JSON still fails instead of being
repaired into a partial object. When the reply is unusable, retry once
at RETRY_REASONING_EFFORT, the project rule in structured_retry, for
both lesson preparation and semantic assessment.

Fixes #2367

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 19:45:55 +06:00
Bingxi Zhao (Frank)
083a9c9b72 fix(mastery): scope duplicate evidence to exact source and objective 2026-10-31 16:56:13 +08:00
Cursor Agent
de3afc8c5b style: fix ruff I001 and format in mastery restatement
Combine same-module imports in the restatement test and collapse the
dict comprehension so CI ruff check/format pass.

Co-authored-by: Nandana Dileep <nandanadileep@users.noreply.github.com>
2026-10-29 03:10:44 +00:00
nandanadileep
7c98b9c1b0 fix: refuse restating a correctly answered mastery 2026-10-28 23:36:28 +00:00
Bingxi Zhao (Frank)
6cb3d53677 fix: preserve mathematical meaning when validating citations 2026-10-27 21:39:14 +08:00
Cursor Agent
d5ed6f563c fix: sort imports in semantic_assessment to satisfy ruff I001
Move `from typing import Literal` above `import unicodedata` so isort
(force-sort-within-sections) matches CI ruff 0.16.0.

Co-authored-by: Nandana Dileep <nandanadileep@users.noreply.github.com>
2026-10-27 12:00:34 +00:00
nandanadileep
b824e69bb0 fix: normalize quote matching in mastery source 2026-10-27 06:41:59 +00:00
Bingxi Zhao (Frank)
e63bb09e6c fix(mastery): budget distinct pixels in grouped assessments (#1901) 2026-10-19 02:57:26 +08:00
yepyhun
ccac56eec1 fix(mastery): bind semantic assessment to verified question evidence 2026-10-13 12:21:04 +02:00