Files
DeepTutor/deeptutor/agents/_shared
Antonio-Faure 1358629d57 fix(chat): keep per-turn-gated tools mounted for the rest of the session
tools[] heads the provider prompt-cache key, so a tool that one turn mounts
and the next drops re-bills the whole history on both turns. Three gates were
still read off a single turn:

- has_kb: detaching the knowledge base removed rag / kb_files /
  knowledge_frontier. They now stay mounted once seen (outside exclusive
  capabilities); while no KB is attached, dispatch passes an empty
  _attached_kb_names and the tools refuse every kb_name, so this never
  reaches a detached KB.
- has_book_authoring: a turn without a single referenced book page dropped
  propose_book_edit. It stays; the tool already refuses without a page.
- has_scientific_research where nothing can be deferred (a partner whitelist
  without load_tools): the message regex mounted the research tools for one
  message only. Once mounted they stay.

Also, the setup capability's message/intro heuristic no longer activates on a
partner turn (which can write nothing and is already not offered the deferred
setup tools); with a whitelist lacking load_tools it mounted the setup tools
and a system block on a fresh install's first message and dropped them next.

Adds tools_gated_by() to tool_composition so the sticky checks name gated
tools from the single _CONDITIONAL_MOUNT_FLAGS table.

Refs #3183
2026-12-02 16:58:59 +08:00
..
2026-09-21 02:30:40 +08:00
2026-09-06 13:46:29 +08:00