From f99b7ebd4f0ebfc5e8e445c37153765d7c89d7ba Mon Sep 17 00:00:00 2001 From: Shanyu Thibaut Juneja Date: Wed, 11 Mar 2026 16:42:22 -0700 Subject: [PATCH] Refines browser state handling and healthcheck Enhances browser command robustness by gracefully handling cases where the DOM state is not yet available, returning an informative error instead of asserting. Updates the container healthcheck to directly probe Chromium's internal CDP port, simplifying the check by removing previous indirection. --- containers/healthcheck.sh | 8 ++++---- strix/tools/browser/browser_commands.py | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/containers/healthcheck.sh b/containers/healthcheck.sh index f364de81..53cd8978 100755 --- a/containers/healthcheck.sh +++ b/containers/healthcheck.sh @@ -1,6 +1,6 @@ #!/bin/bash # Healthcheck script for the strix sandbox container. -# Checks: tool server, Caido proxy, Chromium CDP (via socat). +# Checks: tool server, Caido proxy, Chromium CDP. # Exit 0 = healthy, exit 1 = unhealthy. set -e @@ -21,9 +21,9 @@ if ! curl -sf --max-time 3 -o /dev/null "http://127.0.0.1:${CAIDO_PORT}/graphql/ exit 1 fi -# 3. Chromium CDP must be reachable (via socat forwarder) -if ! curl -sf --max-time 3 "http://127.0.0.1:${CDP_PORT}/json/version" | grep -q "webSocketDebuggerUrl"; then - echo "UNHEALTHY: Chromium CDP not responding on port ${CDP_PORT}" +# 3. Chromium CDP must be reachable (probe internal port directly — no auth needed inside the container) +if ! curl -sf --max-time 3 "http://127.0.0.1:${CDP_INTERNAL_PORT:-19222}/json/version" | grep -q "webSocketDebuggerUrl"; then + echo "UNHEALTHY: Chromium CDP not responding on internal port ${CDP_INTERNAL_PORT:-19222}" exit 1 fi diff --git a/strix/tools/browser/browser_commands.py b/strix/tools/browser/browser_commands.py index ae71dbbb..423d707e 100644 --- a/strix/tools/browser/browser_commands.py +++ b/strix/tools/browser/browser_commands.py @@ -244,7 +244,8 @@ async def _cmd_screenshot( async def _cmd_state(bs: Any) -> dict[str, Any]: state = await bs.get_browser_state_summary() - assert state.dom_state is not None + if state.dom_state is None: + return {"error": "Browser state has no DOM — the page may still be loading"} state_text = state.dom_state.llm_representation() if state.page_info: pi = state.page_info