The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(agent): skip repeated interrupt partial replay
KoNit-K34936950920a
diff --git a/agent/conversation_loop.py b/agent/conversation_loop.pyindex ba97085508a..1eb1725b31e 100644--- a/agent/conversation_loop.py+++ b/agent/conversation_loop.py@@ -28,6 +28,7 @@ from agent.prompt_caching import (strip_anthropic_cache_control,strip_anthropic_tool_cache_control,)+from agent.repetition_guard import is_repetition_dominatedfrom agent.runtime_cwd import resolve_agent_cwdfrom agent.surface_switch import (identity_line_value, note_inert_pinned_tools, split_runtime_boundary, stage_surface_switch_note,@@ -286,6 +287,8 @@ def _apply_active_turn_redirect(agent: Any, messages: List[Dict[str, Any]], textempty-response storms); the interruption scaffold is replay text carried only in the usercorrection's ``api_content``; an on-screen-empty placeholder is ``display_kind=hidden``."""visible = agent._strip_think_blocks(getattr(agent, "_current_streamed_assistant_text", "") or "").strip()+ if is_repetition_dominated(visible):+ visible = ""checkpoint_parts = [_INTERRUPT_SCAFFOLD_MARKER]if visible:diff --git a/tests/agent/test_steer.py b/tests/agent/test_steer.pyindex 13149434b0e..636beea87a2 100644--- a/tests/agent/test_steer.py+++ b/tests/agent/test_steer.py@@ -190,6 +190,34 @@ class TestActiveTurnRedirect:class TestActiveTurnRedirectCheckpoint:+ def test_repetition_dominated_partial_is_not_replayed(self):+ """A looped partial must not seed the correction's next API request."""+ from agent.conversation_loop import _apply_active_turn_redirect++ repeated = ("The same degenerate partial response keeps repeating without progress.\n" * 10)+ agent = _bare_agent()+ agent._current_streamed_assistant_text = repeated+ messages = [{"role": "user", "content": "start"}]++ _apply_active_turn_redirect(agent, messages, "Change course.")++ replayed = messages[-1]["api_content"]+ assert repeated not in replayed+ assert "Visible response before the interruption:" not in replayed++ def test_ordinary_partial_remains_replayable(self):+ """Useful interrupted text remains available to the corrected request."""+ from agent.conversation_loop import _apply_active_turn_redirect++ visible = "I found the migration entry point and was about to inspect it."+ agent = _bare_agent()+ agent._current_streamed_assistant_text = visible+ messages = [{"role": "user", "content": "start"}]++ _apply_active_turn_redirect(agent, messages, "Change course.")++ assert visible in messages[-1]["api_content"]+def test_assistant_tail_puts_correction_last(self):from agent.conversation_loop import _apply_active_turn_redirect