mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-03 13:50:19 +08:00
Prompt caches key on tools, then system, then messages. Every round of a chat-loop turn sends the loop's tool schemas, but the forced finish (round budget spent) sent the request with tool_schemas=None. That changed the very start of the request, so the whole turn history (often 10k-60k tokens) missed the cache on the final round. tool_choice="none" is no fix: on DeepSeek it caches exactly like a request without tools. The forced finish now sends the same tool list the last normal round sent (taken from the request snapshot, since the deferred tool loader appends to the live list after a request goes out) with tool_choice left at auto; the finish instruction already tells the model to stop calling tools. A tool call it returns anyway is never dispatched, and no ask_user draft card is published for it. The round is kept in the history as text only (a call without a result is rejected by the next request; Responses function_call items are dropped too), a repair note asks for a plain-text answer, and one more attempt runs. If that also calls a tool, the turn ends with the existing empty-response fallback. The forced finish still counts as one loop round. The persisted model_turn tools and the context budget now reflect what the final request really carried. The context-exploration pre-pass had the same pattern on its last round (tools dropped); it now keeps the tools, does not run a tool call there, repairs once, and otherwise degrades to the existing single pass. The finish instructions (chat, mastery, explore_context; en/zh) now say the tools are still listed but no call will run. Same approach as the staged pipelines' forced finish (#3080). Refs #3182