mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 04:59:37 +08:00
* fix: keep mastery prompt prefix stable across mode switches * fix: load the outline tools together when a turn switches to outline A study turn that switched to outline loaded mastery_build alone through load_tools; the next turn, in outline mode, mounts every outline tool eagerly, so its tools[] carried one schema more than the previous request and missed the whole cached prefix. The mode switch now loads the outline group into the live request at once. Refs #2922 * fix: close loaded tool schemas the same way as mounted ones Mounted schemas go out with additionalProperties: false; a tool loaded through load_tools did not, so the same tool had two byte forms in tools[]. A tool that moved between mounted and loaded across turns (mastery_build/mastery_revise after an outline->study switch) rewrote the start of the cached prefix. Refs #2922 * fix: keep the outline tools on the deferred loader in outline mode too Outline mode mounted mastery_build/mastery_revise eagerly and skipped the loader, while study and review reached them through it. On an install with no other deferred tool that also dropped load_tools on outline turns, so tools[] changed in both directions around every switch. Refs #2922 * fix: mount mastery navigation from the first mastery turn The first mastery turn usually creates the topic; navigation mounted only once a topic existed, so the second turn's tools[] grew by three schemas and missed the whole cached prefix. Refs #2922 * fix: send only the current mastery mode's rules, as a runtime snapshot The system prompt carried all three mode sections so a mode switch would not rewrite the cached prefix, but that showed the model three conflicting rule sets and relied on a one-line snapshot to pick one. Keep only a short frame in the system prompt and send the current mode's own section inside the mastery_session_mode snapshot, which is appended only when the mode changes. Refs #2922 * fix: keep capability tools recorded by another turn in the session's loaded set A mastery turn records its outline tools (mastery_build, mastery_revise) in the session's loaded_tools.json so a later study turn keeps the same tools[]. A plain chat turn of the same session builds a provider loader without capability names; with an unrestricted caller it treated those names as stale and persisted the set without them, so the next mastery turn mounted fewer tools and re-paid the cached prefix. DeferredToolLoader now keeps names it cannot serve (registered tools it does not own, or names outside its allowlist) as retained: never mounted or reported, but written back with the session state. Only names whose tool is gone from the registry are dropped. Refs #2922