From 791ba307c08cba99ea06ed472460d1739bbbe2bb Mon Sep 17 00:00:00 2001 From: zszz3 <91608029+zszz3@users.noreply.github.com> Date: Mon, 30 Nov 2026 13:24:14 +0800 Subject: [PATCH] docs: place the tool manifest comment and restore docstring accurately The runtime-snapshot comment had drifted above TOOL_MANIFEST_SNAPSHOT instead of RUNTIME_BLOCK_NAMES. _restore_tool_manifest's docstring said a native request never carries a tools snapshot and that the next turn keeps it current; replayed history can carry one, and it is kept only while the previous turn on the same route recorded a rejection. Refs #2973 --- deeptutor/agents/loop/agent_loop.py | 14 +++++++++----- deeptutor/agents/loop/prompt_blocks.py | 6 +++--- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/deeptutor/agents/loop/agent_loop.py b/deeptutor/agents/loop/agent_loop.py index 9e8981567..2fddd9eae 100644 --- a/deeptutor/agents/loop/agent_loop.py +++ b/deeptutor/agents/loop/agent_loop.py @@ -675,11 +675,15 @@ class AgentLoop: def _restore_tool_manifest(self, messages: list[dict[str, Any]]) -> bool: """Put the text tool manifest back after a provider rejected schemas. - Native requests carry no ``[Runtime context: tools]`` snapshot, so the - schema-less retry would show the model no tools at all, and DSML tool - calls could never be written. Added to the canonical ``messages`` it is - persisted with the turn like any snapshot; the next turn replays it and - keeps it current (see ``_tool_schemas_rejected_last_turn``). + A native request adds no ``[Runtime context: tools]`` snapshot of its + own (one may still be in replayed history, possibly retracted), so the + schema-less retry could show the model no current tool list, and DSML + tool calls could never be written. Nothing is added when the latest + ``tools`` snapshot already matches. Added to the canonical ``messages`` + it is persisted with the turn like any snapshot. The next turn replays + it; it stays current only while the previous turn on the same route + recorded a rejection (``_tool_schemas_rejected_last_turn``), otherwise + ``_build_loop_messages`` retracts it. Placement: on the first round the learner's message is still the last message and the provider has not accepted it yet, so the snapshot goes diff --git a/deeptutor/agents/loop/prompt_blocks.py b/deeptutor/agents/loop/prompt_blocks.py index c5dc609cb..15f911172 100644 --- a/deeptutor/agents/loop/prompt_blocks.py +++ b/deeptutor/agents/loop/prompt_blocks.py @@ -21,12 +21,12 @@ from deeptutor.core.context import UnifiedContext from deeptutor.runtime.agentic.tool_dispatch import MAX_PARALLEL_TOOL_CALLS from deeptutor.services.prompt.language import append_language_directive -# These facts can change between turns without changing the tutor's rules. -# They are replayed at their original history position, with a new snapshot -# appended only when their rendered value changes. # The text tool list. Native requests omit it; a schema rejection restores it. TOOL_MANIFEST_SNAPSHOT = "tools" +# These facts can change between turns without changing the tutor's rules. +# They are replayed at their original history position, with a new snapshot +# appended only when their rendered value changes. RUNTIME_BLOCK_NAMES = frozenset( { "runtime_context",