mirror of
https://github.com/NCBM/plyngent.git
synced 2026-11-07 15:37:55 +08:00
core/agent: remove turn-start todo nag -- nag only fires after complete turn
This commit is contained in:
@@ -25,7 +25,6 @@ from .events import UsageEvent
|
||||
from .loop import DEFAULT_MAX_ROUNDS, run_chat_loop
|
||||
from .todo_nag import (
|
||||
DEFAULT_TODO_NAG_STRATEGY,
|
||||
inject_todo_nag_for_stack_with_events,
|
||||
is_synthetic_todo_nag_call_id,
|
||||
parse_todo_nag_strategy,
|
||||
refresh_synthetic_todo_nags,
|
||||
@@ -431,33 +430,6 @@ class ChatAgent:
|
||||
last_request = TokenUsage()
|
||||
try:
|
||||
_turn_nag_strategy: TodoNagStrategy = self.todo_nag_strategy
|
||||
# Turn-start nag before first completion; yield events so CLI flushes
|
||||
# (synthetic_tool → ToolCall/Result chrome, not glued to text).
|
||||
# On retry, a synthetic_tool pair from a previous failed attempt may
|
||||
# have survived rollback (it looks like a committed tool batch).
|
||||
# Skip fresh injection — refresh_synthetic_todo_nags already updated
|
||||
# the content of the surviving pair above.
|
||||
_turn_nag_skipped = (
|
||||
self.todo_stack is not None
|
||||
and not self.todo_stack.is_empty()
|
||||
and _turn_nag_strategy == "synthetic_tool"
|
||||
and _synthetic_todo_pair_after(self.messages, user_index)
|
||||
)
|
||||
if (
|
||||
self.todo_stack is not None
|
||||
and not self.todo_stack.is_empty()
|
||||
and (
|
||||
_turn_nag_strategy != "synthetic_tool" or not _synthetic_todo_pair_after(self.messages, user_index)
|
||||
)
|
||||
):
|
||||
_injected, nag_events = inject_todo_nag_for_stack_with_events(
|
||||
self.messages,
|
||||
self.todo_stack,
|
||||
kind="turn_start",
|
||||
strategy=_turn_nag_strategy,
|
||||
)
|
||||
for nag_event in nag_events:
|
||||
yield nag_event
|
||||
|
||||
async for event in run_chat_loop(
|
||||
self.client,
|
||||
@@ -473,7 +445,6 @@ class ChatAgent:
|
||||
max_context_tokens=self.max_context_tokens,
|
||||
todo_stack=self.todo_stack,
|
||||
todo_nag_strategy=_turn_nag_strategy,
|
||||
turn_start_nag_skipped=_turn_nag_skipped,
|
||||
directive_reminder_tokens=self.directive_reminder_tokens,
|
||||
directive_reminder_text=self.directive_reminder_text,
|
||||
reminder_last_band=self.reminder_last_band,
|
||||
|
||||
@@ -386,7 +386,6 @@ async def run_chat_loop( # noqa: C901, PLR0912 — multi-phase tool loop
|
||||
max_context_tokens: int = DEFAULT_CONTEXT_MAX_TOKENS,
|
||||
todo_stack: TodoStack | None = None,
|
||||
todo_nag_strategy: TodoNagStrategy = DEFAULT_TODO_NAG_STRATEGY,
|
||||
turn_start_nag_skipped: bool = False,
|
||||
directive_reminder_tokens: int = DEFAULT_DIRECTIVE_REMINDER_TOKENS,
|
||||
directive_reminder_text: str | None = None,
|
||||
reminder_last_band: int = 0,
|
||||
@@ -480,19 +479,12 @@ async def run_chat_loop( # noqa: C901, PLR0912 — multi-phase tool loop
|
||||
if not has_tools:
|
||||
if todo_stack is not None and todo_stack.needs_review() and not todo_review_injected:
|
||||
todo_review_injected = True
|
||||
# On retry, the turn-start nag was skipped (pair survived
|
||||
# rollback). The model already has the stack reminder
|
||||
# in-history — skip the end-of-turn duplicate.
|
||||
if turn_start_nag_skipped:
|
||||
injected = False
|
||||
nag_events: list[AgentEvent] = []
|
||||
else:
|
||||
injected, nag_events = inject_todo_nag_for_stack_with_events(
|
||||
messages,
|
||||
todo_stack,
|
||||
kind="end_of_turn",
|
||||
strategy=todo_nag_strategy,
|
||||
)
|
||||
injected, nag_events = inject_todo_nag_for_stack_with_events(
|
||||
messages,
|
||||
todo_stack,
|
||||
kind="end_of_turn",
|
||||
strategy=todo_nag_strategy,
|
||||
)
|
||||
for nag_event in nag_events:
|
||||
yield nag_event
|
||||
if injected:
|
||||
|
||||
Reference in New Issue
Block a user