#1923·agent-zero

Browser plugin: dead worker event-loop thread permanently hangs the agent turn (no timeout in BrowserRuntime.call_for, cancellation absorbed forever)

Author: nico7masterCreated Sep 26, 2026Updated Sep 26, 2026

Summary

In dockerized Agent Zero, when the browser plugin's worker DeferredTask event-loop thread dies (in our incident, as collateral of the backend event-loop wedge reported in #1889), every subsequent browser-runtime call made from an agent turn awaits a concurrent.Future that never resolves. The turn then freezes at "Building prompt" indefinitely; new user messages only become interventions on the zombie turn, and the turn's own cancellation path cannot complete either, because its cleanup is scheduled on the same dead worker. Proven live on 2026-09-26 with in-process coroutine dumps: the turn task sat at await asyncio.shield(result) inside call_for, and the very same Future object was still pending in dumps taken 10+ minutes apart.

Reproduction

  1. Let the browser worker thread die (e.g. during a backend wedge — see #1889).
  2. Send any message to a chat whose agent has the browser tool enabled.
  3. The turn hangs at "Building prompt" forever; nudging does not recover the chat (new messages pile onto the zombie turn as interventions).
  4. In-process diagnostic (walk task.get_coro() / cr_await chain on the chat's loop thread): the turn is suspended in BrowserRuntime.call_for at the un-timed await; the wrapped future is pending — identical object across dumps taken 10 minutes apart.
  5. Setting an exception on that pending Future from outside (future.set_exception(RuntimeError(...))) unblocks the turn immediately, and it completes normally — the prompt extension's try/except swallows the error. This confirms the pending Future is the sole blocker.

Root cause

plugins/_browser/helpers/runtime.py, BrowserRuntime.call_for (line 659):

  • Line 681: future = self._worker.event_loop_thread.run_coroutine(runner()) — dispatches onto the worker loop. If that thread is dead, nothing will ever complete this Future. There is no timeout anywhere on this path.
  • Line 684: return await asyncio.shield(result) — waits forever.
  • Lines 685–700: the CancelledError path schedules cancel_and_wait() on the same dead worker (run_coroutine(cancel_and_wait())), then while not cleanup.done(): await asyncio.shield(cleanup) with except asyncio.CancelledError: pass. The cleanup Future can never resolve on a dead worker, so this loop absorbs every further cancellation — the turn is unkillable in practice.

Call sites are un-timed and fail-soft on exceptions — but a dead worker never raises, it just never returns. plugins/_browser/extensions/python/message_loop_prompts_after/_20_browser_context.py:

  • line 27: listing = await runtime.call("list")
  • lines 45–46: await runtime.call("state", ...), await runtime.call("content", ...)

Net effect: one dead worker thread converts into a permanently wedged chat — no error, no log, no recovery path.

Proposed fix (minimal)

  1. Dead-worker fast fail in call_for: if the worker loop thread is not alive, raise RuntimeError("browser worker event loop is not running") before dispatching (helpers/defer.py EventLoopThread.is_alive() already exists).
  2. Bound the cross-thread wait: wrap the awaited future in asyncio.wait_for(..., timeout=...) (configurable; tens of seconds is ample for list/state/content) and convert to a clear exception so the existing try/except call sites fail soft.
  3. Bound the cancellation cleanup: cap the while not cleanup.done() wait (e.g. a few seconds), then re-raise instead of absorbing cancellation forever.

Conservative alternative (deployed locally, verified): keep core untouched and bound at the call sites — our usr-space override of the prompt extension wraps get_runtime and runtime.call("list") in asyncio.wait_for(..., 20) and simply omits the extras on timeout; the chat continues normally even with a dead worker.

Before / after

Scenario Current With fix
Worker alive works works
Worker dead — prompt extension call turn hangs forever at "Building prompt" clear exception after timeout; extras omitted; turn proceeds
Worker dead — other runtime.calls (tools) hangs forever clear error surfaced to the model
Cancel/stop while zombied cancellation absorbed by cleanup wait-loop bounded cleanup, then raises

Environment

  • Agent Zero, dockerized (single container), current release as of Sep 2026; Python 3.12 runtime.
  • Incident 2026-09-26; trigger was the #1889 wedge, but any death of the worker thread reproduces the permanent hang.

Cross-reference

  • #1889 — backend event-loop wedge. This is a resilience follow-up: even after the main loop recovers from a wedge, chats that touch the browser plugin remain wedged until manually healed. Also relevant to #1889's loop-liveness recommendation: a per-worker liveness check would surface this instantly.