diff --git a/run_agent.py b/run_agent.py index d13346247..78ceabe61 100644 --- a/run_agent.py +++ b/run_agent.py @@ -4692,6 +4692,14 @@ class AIAgent: # Use the Anthropic SDK's streaming context manager with self._anthropic_client.messages.stream(**api_kwargs) as stream: for event in stream: + # Update stale-stream timer on every event so the + # outer poll loop knows data is flowing. Without + # this, the detector kills healthy long-running + # Opus streams after 180 s even when events are + # actively arriving (the chat_completions path + # already does this at the top of its chunk loop). + last_chunk_time["t"] = time.time() + if self._interrupt_requested: break @@ -4715,6 +4723,7 @@ class AIAgent: if text and not has_tool_use: _fire_first_delta() self._fire_stream_delta(text) + deltas_were_sent["yes"] = True elif delta_type == "thinking_delta": thinking_text = getattr(delta, "thinking", "") if thinking_text: