The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(agent): withhold the reconnect notice too for a wedged inline call
unsupportedpastels930e5ed557ed
diff --git a/agent/chat_completion_stream_monitor.py b/agent/chat_completion_stream_monitor.pyindex bcbdf891e38..47d309e1b10 100644--- a/agent/chat_completion_stream_monitor.py+++ b/agent/chat_completion_stream_monitor.py@@ -60,8 +60,8 @@ class StreamingWaitMonitor:"reporting it as active, so the inactivity watchdog can end it. model=%s",self._same_attempt_kills, attempt, self.api_kwargs.get("model", "unknown"))self._liveness_withheld_at = self.last_chunk_time["t"]- self.agent._emit_diagnostic_wait(f"⚠ no output from provider for {int(elapsed)}s — reconnecting...")- if self._claims_liveness():+ if self._claims_liveness(): # the reconnect notice touches activity too (_emit_wait_notice)+ self.agent._emit_diagnostic_wait(f"⚠ no output from provider for {int(elapsed)}s — reconnecting...")self.agent._touch_activity(f"stale stream detected after {int(elapsed)}s, reconnecting")def _forget_invisible_deltas(self, exc) -> bool:diff --git a/tests/agent/test_stream_stale_abandon.py b/tests/agent/test_stream_stale_abandon.pyindex c84a4e6c549..bdbfc692e3b 100644--- a/tests/agent/test_stream_stale_abandon.py+++ b/tests/agent/test_stream_stale_abandon.py@@ -189,9 +189,13 @@ def test_wedged_inline_call_stops_reporting_activity(wedged, monkeypatch, caplogmonkeypatch.setattr(wedged, "_touch_activity", lambda desc, **kw: (touches.append(desc), real_touch(desc, **kw)))real_rearm = helpers._StreamingCall._rearm_or_abandon_after_kill+ held_from = [] # len(touches) right after the kill that started the hold+def _rearm(self, elapsed):calls.append(self)real_rearm(self, elapsed)+ if self._liveness_withheld_at is not None and not held_from:+ held_from.append(len(touches))monkeypatch.setattr(helpers._StreamingCall, "_rearm_or_abandon_after_kill", _rearm)with caplog.at_level("WARNING"):@@ -199,6 +203,7 @@ def test_wedged_inline_call_stops_reporting_activity(wedged, monkeypatch, caplogcaller.join(timeout=2.5) # about 8 stale windows: well past the limitkills = _log_count(caplog, "Stream stale for")stale_touches = [t for t in touches if t.startswith("stale stream detected")]+ after_hold = touches[held_from[0]:] if held_from else Nonecall = calls[-1]before = len(touches)call._heartbeat(10)@@ -208,6 +213,8 @@ def test_wedged_inline_call_stops_reporting_activity(wedged, monkeypatch, caplogassert caller.is_alive(), "an inline call runs on the caller's thread and is not abandoned"assert kills > 3assert len(stale_touches) == 2, f"kills past the limit still reported activity: {stale_touches}"+ # Every activity path counts (the reconnect notice touches activity too), not only the kill's own touch.+ assert after_hold == [], f"activity was still reported during the hold: {after_hold}"assert heartbeat_touches == 0, "the heartbeat kept reporting a wedged inline call as active"assert _log_count(caplog, "no longer reporting it as active") == 1assert _log_count(caplog, "abandoning the request") == 0