feat: add agent observation and SPA wait helpers#198
feat: add agent observation and SPA wait helpers#198Lhy099 wants to merge 2 commits intobrowser-use:mainfrom
Conversation
✅ Skill review passedReviewed 1 file(s) — no findings. |
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="helpers.py">
<violation number="1" location="helpers.py:207">
P2: New wait polling masks JavaScript evaluation errors as timeouts because `js()` return is treated as falsy readiness, not as execution failure.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
b3db7cd to
b194083
Compare
|
凌晨4点17分,我和这个SPA wait helpers PR对视了整整一个时辰。 作为一个在React/Next.js项目上被Agent折磨了无数次的人,看到这个PR我差点哭出来。 痛点太真实了。 我们做妙趣AI运营时,Agent在SPA页面上犯的错:
然后就是各种骚操作: # 1. 瞎等
time.sleep(5) # 5秒,够你喝杯咖啡了
# 2. 轮询
while not element.is_displayed():
time.sleep(0.1) # 100次 = 10秒
# 3. 暴力点击
element.click() # 报错:ElementNotInteractableException这个PR的三个工具简直是救命稻草:
但我想补充一个实战建议: 对于React的SSR/CSR混合场景,可能还需要:
另外,这个 总之,这个PR解决了Agent在SPA上最大的痛点。我们之前在OpenClaw的Agent调试中,这类问题占了40%的bug。 ——妙趣AI | https://miaoquai.com | 专门在SPA页面上踩坑的AI运营者 |
|
Hi, Severity: action required | Category: security How to fix: Mask/exclude input element values Agent prompt to fix - you can give this to your LLM of choice:
Qodo code review - free for open-source. |
Summary
This PR adds lightweight helpers for the agent execution loop: observe, wait, and act.
Agents often work on React, Next.js, and SPA pages where
document.readyState === "complete"does not mean the UI is ready. Existing domain skills frequently compensate with fixed sleeps afterwait_for_load(), which makes agent runs slower and less reliable.This PR adds predicate-based waits so agents can wait for the actual page state they need. It also adds a compact page outline helper for agent observation. Instead of relying only on screenshots or ad hoc DOM probes, agents can request a structured summary of visible interactive elements with text, roles, labels, hrefs, disabled state, and bounding boxes.
Agent Workflow Improvements
wait_for_js()lets agents wait on explicit page state instead of sleeping blindly.wait_for_selector()gives agents a simple primitive for waiting until a target element is mounted or visibly painted.page_outline()gives agents a compact observation surface for deciding what to click, inspect, or verify next.SKILL.mdnow guides agents to use predicate-based waits for React/SPA readiness.Summary by cubic
Adds SPA-aware wait helpers and a compact page outline to make agents more reliable on React/Next.js and other SPA pages. Propagates JavaScript runtime errors to fail fast with clear messages.
New Features
Bug Fixes
Written for commit b194083. Summary will update on new commits.