Files
DeepTutor/tests/runtime
wojiecihuo 779e9da342 fix: keep the mastery prompt prefix stable across mode switches (#2991)
* 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
2026-11-28 12:20:01 +08:00
..
2026-09-21 02:30:40 +08:00
2026-04-23 19:29:16 +08:00
2026-07-31 00:25:48 +08:00
2026-09-06 13:46:29 +08:00
2026-08-02 13:07:32 +08:00
2026-09-03 01:38:54 +08:00