Skip to content

The agent that grows with you

fix(agent): name a provider retry backoff on the live status line

brooklyn!a3e731bb741e
diff --git a/agent/turn_recovery.py b/agent/turn_recovery.py
index b71d7862c8f..9104185887d 100644
--- a/agent/turn_recovery.py
+++ b/agent/turn_recovery.py
@@ -1080,6 +1080,14 @@ def compute_error_backoff(
agent._emit_status(_retry_status)
else:
agent._buffer_status(_retry_status)
+ # The buffered line only replays if every retry fails; the live status
+ # line is the one thing the user sees meanwhile. Name the wait there so a
+ # 60s backoff after a 5xx is not an anonymous spinner — this is transient
+ # (rewritten by the next frame, cleared on recovery), so it does not add
+ # the transcript chatter the buffer exists to avoid.
+ agent._emit_wait_notice(
+ f"⏳ waiting on provider — retrying in {wait_time:.0f}s (attempt {retry_count}/{max_retries})"
+ )
logger.warning(
"Retrying API call in %ss (attempt %s/%s) %s policy=%s error=%s",
wait_time, retry_count, max_retries, agent._client_log_context(),
diff --git a/tests/agent/test_turn_recovery_retry_notice.py b/tests/agent/test_turn_recovery_retry_notice.py
new file mode 100644
index 00000000000..4a3f57b3c33
--- /dev/null
+++ b/tests/agent/test_turn_recovery_retry_notice.py
@@ -0,0 +1,32 @@
+"""A provider retry backoff names itself on the live status line.
+
+The buffered retry status replays only if every retry fails, so during the
+backoff itself the user used to see an anonymous spinner — and right after a
+tool that just finished (a connector sign-in landing, say) it read as the
+agent going silent. The wait notice is transient (rewritten by the next
+frame, cleared on recovery) and rides the frame long provider waits already
+use, so it adds none of the transcript chatter the buffer exists to avoid."""
+
+from unittest.mock import MagicMock
+
+from agent.turn_recovery import compute_error_backoff
+
+
+def test_retry_backoff_names_the_wait_on_the_live_status_line():
+ agent = MagicMock()
+ agent._client_log_context.return_value = ""
+
+ wait = compute_error_backoff(
+ agent, RuntimeError("502"), retry_count=1, max_retries=3,
+ is_rate_limited=False, is_zai_coding_overload=False,
+ base_url="https://example.test/v1", model="test/model",
+ )
+
+ assert wait > 0
+ # Still buffered for the exhausted-retries replay …
+ agent._buffer_status.assert_called_once()
+ # … and named live while the backoff runs.
+ agent._emit_wait_notice.assert_called_once()
+ text = agent._emit_wait_notice.call_args.args[0]
+ assert text.startswith("⏳ waiting on provider")
+ assert "attempt 1/3" in text