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
This commit is contained in:
zszz3
2026-11-30 13:24:14 +08:00
parent 91e04886be
commit 791ba307c0
2 changed files with 12 additions and 8 deletions

View File

@@ -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

View File

@@ -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",