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