mirror of
https://github.com/openswarm-ai/openswarm.git
synced 2026-09-12 20:57:42 +02:00
[eric] browser: long click names are card blobs not send controls, prefix no longer cut short
This commit is contained in:
@@ -309,7 +309,12 @@ def first_unsafe_step(steps: list[dict]) -> tuple[int, str]:
|
||||
p = s.get("params", {}) or {}
|
||||
probe = None
|
||||
if tool in ("BrowserClickByName", "BrowserClick"):
|
||||
probe = {"action": "click", "name": p.get("name") or p.get("selector") or ""}
|
||||
name = p.get("name") or p.get("selector") or ""
|
||||
# Real Send controls have short names ("Send", "Send InMail"); a
|
||||
# 100ch profile-card blob containing "Send a..." is not one, and
|
||||
# flagging it cut a 6-step prefix to 1 (measured, r19).
|
||||
if len(name) <= 40:
|
||||
probe = {"action": "click", "name": name}
|
||||
elif tool == "BrowserType":
|
||||
probe = {"action": "type", "selector": p.get("selector") or ""}
|
||||
if probe and browser_batch_replay.is_send_step(probe):
|
||||
|
||||
@@ -525,3 +525,17 @@ def test_template_task_ignores_possessive_apostrophes():
|
||||
assert "chen's linkedin" in t14
|
||||
assert _sig(r14) == _sig(r15)
|
||||
assert template_task("no quotes here at all") == ("no quotes here at all", [])
|
||||
|
||||
|
||||
def test_long_card_blob_click_names_are_not_send_steps():
|
||||
from backend.apps.agents.browser.browser_skills import first_unsafe_step
|
||||
flow = [
|
||||
{"tool": "BrowserNavigate", "params": {"url": "https://www.linkedin.com/search"}},
|
||||
{"tool": "BrowserClickByName", "params": {"name": (
|
||||
"Tyler Chen Premium • 1st Something Here Irvine, California, United States Send a message to Tyler"
|
||||
)}},
|
||||
{"tool": "BrowserClickByName", "params": {"name": "Message"}},
|
||||
{"tool": "BrowserClickByName", "params": {"name": "Send"}},
|
||||
]
|
||||
i, why = first_unsafe_step(flow)
|
||||
assert i == 3, f"expected the short Send click flagged, got {i}: {why}"
|
||||
|
||||
Reference in New Issue
Block a user