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.
This commit is contained in:
Shanyu Thibaut Juneja 2026-03-11 16:42:22 -07:00 committed by STJ
parent bbf6e08bab
commit f99b7ebd4f
2 changed files with 6 additions and 5 deletions

View file

@ -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

View file

@ -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