Skip to content

The agent that grows with you

fix(agent): close stopped empty recovery with its reason

JoaoMarcos44cc780047da5b
diff --git a/agent/turn_recovery.py b/agent/turn_recovery.py
index d757a745fd8..1e2eff9b506 100644
--- a/agent/turn_recovery.py
+++ b/agent/turn_recovery.py
@@ -1268,6 +1268,10 @@ def abort_turn_on_interrupt(
"""Announce ``abort_message``, close any open tool sequence with ``interrupt_text``,
persist, clear the interrupt and return the ``interrupted`` result dict."""
_vlines(agent, f"⚡ {abort_message}")
+ # Empty-response recovery can leave a synthetic assistant+nudge pair after an
+ # already-executed tool result. Strip only that request-local scaffold before
+ # closing, so this exit owner can persist its specific interrupt reason.
+ agent._drop_trailing_empty_response_scaffolding(messages)
close_interrupted_tool_sequence(messages, interrupt_text)
agent._persist_session(messages, conversation_history)
# The turn was stopped, not rebuilt: a pending steer was aimed at this turn's next