diff --git a/agent/conversation_loop.py b/agent/conversation_loop.py index 073a475fa0..c0af0e865f 100644 --- a/agent/conversation_loop.py +++ b/agent/conversation_loop.py @@ -613,11 +613,11 @@ def run_conversation( truncated_response_parts: List[str] = [] compression_attempts = 0 _turn_exit_reason = "unknown" # Diagnostic: why the loop ended - # Last composed answer intentionally held back by an internal continuation - # gate. If the continuation consumes the remaining budget, this is the - # best user-facing result available; it must not be confused with error or + # Last composed answer intentionally held back by a verification gate. If + # that continuation consumes the remaining budget, this is the best + # user-facing result available; it must not be confused with error or # recovery text produced by unrelated exit paths. - _pending_continuation_response = None + _pending_verification_response = None # Per-turn tally of consecutive successful credential-pool token refreshes, # keyed by (provider, pool-entry-id). A persistent upstream 401 lets @@ -5182,7 +5182,7 @@ def run_conversation( # continuation-budget exhaustion. ``final_response`` itself # must be cleared so the finalizer can distinguish this gate # from unrelated error/recovery exits. (#61631) - _pending_continuation_response = final_response + _pending_verification_response = final_response final_response = None continue @@ -5235,7 +5235,7 @@ def run_conversation( agent._session_messages = messages logger.debug("pre_verify nudge issued (attempt %d)", agent._pre_verify_nudges) - _pending_continuation_response = final_response + _pending_verification_response = final_response final_response = None continue @@ -5321,7 +5321,7 @@ def run_conversation( original_user_message=original_user_message, _should_review_memory=_should_review_memory, _turn_exit_reason=_turn_exit_reason, - _pending_continuation_response=_pending_continuation_response, + _pending_verification_response=_pending_verification_response, ) diff --git a/agent/turn_finalizer.py b/agent/turn_finalizer.py index 87f0a6c1b5..17961eda22 100644 --- a/agent/turn_finalizer.py +++ b/agent/turn_finalizer.py @@ -42,7 +42,7 @@ def finalize_turn( original_user_message, _should_review_memory, _turn_exit_reason, - _pending_continuation_response=None, + _pending_verification_response=None, ): """Run the post-loop finalization and return the turn ``result`` dict. @@ -57,7 +57,7 @@ def finalize_turn( ) continuation_budget_exhausted = ( final_response is None - and bool(_pending_continuation_response) + and bool(_pending_verification_response) and budget_exhausted ) @@ -68,7 +68,7 @@ def finalize_turn( # one. Preserve that exact answer instead of replacing it with another # fallible model call. The explicit pending value is the provenance # guard: unrelated error/recovery exits can never enter this branch. - final_response = _pending_continuation_response + final_response = _pending_verification_response _turn_exit_reason = f"max_iterations_reached({api_call_count}/{agent.max_iterations})" iteration_limit_fallback = True elif final_response is None and budget_exhausted: diff --git a/tests/agent/test_turn_finalizer_iteration_limit_exit.py b/tests/agent/test_turn_finalizer_iteration_limit_exit.py index ecca23992b..ab09903887 100644 --- a/tests/agent/test_turn_finalizer_iteration_limit_exit.py +++ b/tests/agent/test_turn_finalizer_iteration_limit_exit.py @@ -84,7 +84,7 @@ def _finalize( final_response, exit_reason, api_call_count=60, - pending_continuation_response=None, + pending_verification_response=None, ): return finalize_turn( agent, @@ -100,7 +100,7 @@ def _finalize( original_user_message="task", _should_review_memory=False, _turn_exit_reason=exit_reason, - _pending_continuation_response=pending_continuation_response, + _pending_verification_response=pending_verification_response, ) @@ -114,7 +114,7 @@ def test_pending_verify_response_is_preserved_for_cron_delivery(monkeypatch): agent, final_response=None, exit_reason="unknown", - pending_continuation_response=report, + pending_verification_response=report, ) assert result["final_response"] == report @@ -131,7 +131,7 @@ def test_pending_pre_verify_response_is_preserved_on_budget_exhaustion(monkeypat agent, final_response=None, exit_reason="budget_exhausted", - pending_continuation_response=report, + pending_verification_response=report, ) assert result["final_response"] == report @@ -193,7 +193,7 @@ def test_pending_response_records_kanban_timeout(monkeypatch): agent, final_response=None, exit_reason="unknown", - pending_continuation_response="composed report", + pending_verification_response="composed report", ) assert result["turn_exit_reason"] == "max_iterations_reached(60/60)"