mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 07:30:05 +08:00
* fix: keep sent runtime snapshots in mastery replay Mastery replay dropped every runtime snapshot from history and the loop re-appended them after it, so each follow-up request diverged from the previous one at message 1 and only tools + system hit the prompt cache. - project_mastery_replay(keep_snapshots=True) for the tutor request and its token accounting; memory material still drops snapshots - replay_group no longer blanks a tagged mastery_status_snapshot while removing the legacy fused suffix - status snapshot anchors are numbered from the start (occurrence), so a later snapshot never changes how an earlier turn is projected Refs #2922 * fix: keep runtime snapshots out of the mastery history budget Replayed snapshots stay in the request so follow-up turns extend the cached prefix, but counting them made a large mastery_status snapshot push the history over its 20k budget after two turns; the next turn then paid a memory rewrite and a full prefix miss. The budget now measures the learning history only, as before. Refs #2922 * fix: bound the runtime snapshots kept in mastery history Keeping sent snapshots out of the history budget entirely let many short exchanges accumulate them without limit (80 quiz-style turns: 5.4k counted, 62k sent). Dialogue still keeps to the plan; dialogue plus snapshots keep to twice the plan, and only as far as the model's window allows. Refs #2922 * fix: keep only this turn's state in the mastery status snapshot Every mastery turn sends a fresh mastery_status snapshot and, since the replay change, keeps earlier ones in history, so whatever a snapshot carries is paid for once per turn and then kept. A full status read repeats fixed guidance (open question, question group, working brief, intake, teaching guidance and focus) and every default value of every knowledge point. The snapshot now drops empty and default values and the fixed guidance. That guidance lives in named constants and is stated once in a new mastery_status_guide system block, which also explains the omitted defaults. Snapshots start with a one-line header; history sharing reads both the header and the longer notice older sessions stored. An explicit mastery_status call still returns the full payload. Measured over 54 recorded snapshots: working briefs 1,454 -> 645 tokens (median), full outline snapshots 6,352 -> 2,954. The guide adds 861 tokens (en) to the cached system prompt. Refs #2922 * fix: size the exact tail the way the plan does, and share full reads with compact snapshots Two gaps left by keeping snapshots in mastery replay (review on #2992): - Recent-history selection counted kept snapshots in full while the plan discounted them, so a session of short exchanges with large snapshots archived most of them as soon as selection ran. ContextBuilder now sizes the candidate tail through _recent_history_tokens(), and the mastery builder answers with the same _plan_tokens() measure. - Snapshots carry the compact form of map, learner_profile, learning_stages and visual_requirements, so a later full mastery_status result never matched them exactly. Sharing now also compares a full field's compact form and marks such references with "defaults_omitted": true, which the state reference notice explains. Also: rename _next to _compact_next_step, and say in the status guide that the omitted-default rules cover only what the snapshot includes. Refs #2922