Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fix: gate skeleton-screen hint on in-flight network requests

MagMueller5adce7bf9b68
diff --git a/browser_use/agent/prompts.py b/browser_use/agent/prompts.py
index d1cb608b8..73e63a8d8 100644
--- a/browser_use/agent/prompts.py
+++ b/browser_use/agent/prompts.py
@@ -229,8 +229,13 @@ class AgentMessagePrompt:
stats_text = '<page_stats>'
if page_stats['total_elements'] < 10:
stats_text += 'Page appears empty (SPA not loaded?) - '
- # Skeleton screen: many elements but almost no text = loading placeholders
- elif page_stats['total_elements'] > 20 and page_stats['text_chars'] < page_stats['total_elements'] * 5:
+ # Skeleton screen: low text density only means "loading" while requests are actually in flight;
+ # without that gate the hint fires on most fully-rendered element-heavy pages (measured 76% of prompts)
+ elif (
+ self.browser_state.pending_network_requests
+ and page_stats['total_elements'] > 20
+ and page_stats['text_chars'] < page_stats['total_elements'] * 5
+ ):
stats_text += 'Page appears to show skeleton/placeholder content (still loading?) - '
stats_text += f'{page_stats["links"]} links, {page_stats["interactive_elements"]} interactive, '
stats_text += f'{page_stats["iframes"]} iframes'
diff --git a/tests/ci/test_action_blank_page.py b/tests/ci/test_action_blank_page.py
index 98f3995b7..9f03d9e3c 100644
--- a/tests/ci/test_action_blank_page.py
+++ b/tests/ci/test_action_blank_page.py
@@ -135,6 +135,12 @@ class TestSkeletonScreenDetection:
await _navigate(tools, browser_session, f'{base_url}/skeleton')
state = await browser_session.get_browser_state_summary(include_screenshot=False)
+ # The hint is gated on in-flight requests; the static fixture has none, so simulate one
+ from browser_use.browser.views import NetworkRequest
+
+ state.pending_network_requests = [
+ NetworkRequest(url=f'{base_url}/api/data', method='GET', loading_duration_ms=120.0, resource_type='fetch')
+ ]
prompt = _make_prompt(state)
description = prompt._get_browser_state_description()