Commit Graph

5109 Commits

Author SHA1 Message Date
Gregor Žunič d1d6e8f77c fix(agent): harden code mode JavaScript execution 2026-07-10 23:01:06 -07:00
Gregor Žunič adf7b61a3c feat(agent): enable raw CDP code mode by default 2026-07-10 00:50:50 -07:00
Gregor Žunič 4693997efc feat(agent): add native raw CDP code mode 2026-07-10 00:47:32 -07:00
Laith Weinberger 36a8525c13 lint 2026-07-07 17:11:55 -07:00
Laith Weinberger 2de48f89b8 hint for unknown CLI cmds 2026-07-07 17:01:10 -07:00
Laith Weinberger 9fb49e03ee sync browser-use skill from harness main (cloud-browser section) 2026-07-07 16:29:37 -07:00
Laith Weinberger c93a1de56f hint if trying to use browser-use cmd 2026-07-07 16:17:14 -07:00
laithrw d1af39626e Merge branch 'main' into feat/delegate-cli-telemetry-to-harness 2026-07-07 10:48:36 -07:00
Laith Weinberger 8e279db893 global var 2026-07-07 10:38:35 -07:00
Laith Weinberger 803fd85f97 remove telemetry 2026-07-07 10:27:38 -07:00
Laith Weinberger 55a56c31c4 improve CLI hint 2026-07-07 10:07:15 -07:00
laithrw 53b1316076 Merge branch 'main' into skill-rename-regex 2026-07-08 00:02:34 +08:00
laithrw 2d01ea316f Merge branch 'main' into fix/cli-slowdown 2026-07-07 23:48:25 +08:00
Laith Weinberger 61e069d1ed Merge branch 'fix/cli-slowdown' of https://github.com/browser-use/browser-use into fix/cli-slowdown 2026-07-07 08:47:48 -07:00
Laith Weinberger c04c724c97 timeout 2026-07-07 08:46:53 -07:00
Laith Weinberger 425bcb8de3 rename browser harness -> use except urls 2026-07-06 17:52:00 -07:00
Saurav Panda 9863fe17fb Fix visibility check mutating shared snapshot bounds
is_element_visible_according_to_all_parents mutated snapshot_node.bounds in
place while walking the frame chain, permanently shifting every checked
node's coordinates by frame offsets and scroll — corrupting values shared
with absolute_position math, paint-order filtering, and any later visibility
check (the function was not even idempotent).

Worse, a frame node appears in its own frame chain (_construct_enhanced_node
appends it before computing visibility), so an iframe's bounds were offset
by themselves — coordinates doubled — wrongly classifying iframes past
half the viewport threshold as invisible and silently dropping their entire
content subtree from extraction.

Work on a copy of the bounds and skip self in the frame chain.
2026-07-06 17:40:46 -07:00
laithrw 285ba3b401 Merge branch 'main' into fix/cli-slowdown 2026-07-07 08:29:32 +08:00
Laith Weinberger b1bf5281ad better error tracking 2026-07-06 17:28:02 -07:00
Laith Weinberger 9ee4929912 don't slow down CLI 2026-07-06 17:15:17 -07:00
Saurav Panda 248f98f208 Merge branch 'main' into fix/llm-output-truncation 2026-07-07 07:51:02 +08:00
Saurav Panda 2afef14667 Trim comments to essentials 2026-07-06 16:47:27 -07:00
Saurav Panda e672ab6de7 Detect truncation before the missing-content guard
OpenAI reasoning models can spend the entire max_completion_tokens budget on
hidden reasoning, returning finish_reason='length' with content=null. The
truncation check ran after the missing-content guard, so that case raised
the generic 'Failed to parse structured output' (500) instead of
ModelOutputTruncatedError — no truncation signal, no fallback switch. Check
finish_reason first; it does not depend on content.
2026-07-06 16:45:33 -07:00
Laith Weinberger b65642f810 shim for legacy CLI cmds 2026-07-06 16:40:41 -07:00
Saurav Panda db70a813c1 Let truncation errors switch to the fallback LLM
The 400 status chosen for truncation errors (deliberately outside provider
retry lists — an identical retry truncates identically) also fell outside
Agent._try_switch_to_fallback_llm's allowlist, so a configured fallback_llm
could no longer rescue a truncated run. Before this PR the downstream parse
failure was wrapped as a 502 ModelProviderError, which did allow the switch.

Introduce ModelOutputTruncatedError(ModelProviderError, status 400): the
three providers raise it, provider retry loops still skip it, and the
agent's fallback check treats it as switchable explicitly — a fallback with
a different output cap can succeed where the primary truncated.
2026-07-06 16:31:18 -07:00
Saurav Panda db2b2c67f9 Describe truncation gracefully when the token cap is unset
max_completion_tokens (OpenAI) and max_output_tokens (Google) are optional;
when set to None the truncation message printed 'truncated at
max_output_tokens=None'. Fall back to "the model's output token limit" —
a MAX_TOKENS/length finish reason means some server-side cap fired even
with no client-side cap configured. Anthropic's max_tokens is non-optional
and unaffected.
2026-07-06 15:56:03 -07:00
Saurav Panda 5f690c207e Detect LLM output truncation instead of failing with misleading parse errors
Structured output cut off at the completion-token cap was never detected:
OpenAI's finish_reason='length', Anthropic's stop_reason='max_tokens', and
Gemini's MAX_TOKENS finish reason all produced JSON cut mid-string, which
surfaced as an opaque parse error ('Unterminated string starting at...') —
or worse, a valid-but-chopped prefix. The actual cause (output token cap)
was never mentioned, and with defaults like max_completion_tokens=4096 this
regularly hits long done()/extract outputs.

Each provider now checks the finish/stop reason before parsing structured
output and raises a clear ModelProviderError ('Model output was truncated
at max_*_tokens=N; increase it or request shorter output'). Status code 400
is used deliberately: it is not in any retry list, and retrying the same
request would truncate identically.

Also adds an 'except ModelProviderError: raise' guard in the Anthropic
handler so the new error is not re-wrapped by the generic catch-all.
2026-07-06 15:17:52 -07:00
Saurav Panda 782535c34f Keep plain BrowserErrors recoverable: only structured ones bypass the generic handler
An unconditional re-raise sent BrowserErrors without long_term_memory (e.g.
upload_file's failure paths) into Tools.act's handle_browser_error, which
re-raises exactly those — escaping act() as an exception where callers
previously got a recoverable ActionResult(error=...).

Guard the bypass on long_term_memory being present (the exact condition
handle_browser_error formats without re-raising; short_term_memory alone
would still re-raise), and flatten plain BrowserErrors to RuntimeError as
before. Regression test covers the plain-BrowserError path through
tools.act.
2026-07-06 15:04:37 -07:00
Saurav Panda f30c3952c9 Preserve BrowserError's structured memory through execute_action
Registry.execute_action's catch-all handler flattened BrowserError into a
generic 'Error executing action ...' RuntimeError, destroying the structured
short_term_memory/long_term_memory the error carries to steer the LLM's next
action (e.g. the list of available dropdown options when clicking a select).
The 'except BrowserError' branch in Tools.act that formats those memories
into an ActionResult was dead code for any action that let a BrowserError
propagate (upload_file, dropdown_options via event_result, extraction
handlers).

Re-raise BrowserError before the generic handlers so handle_browser_error
becomes the single formatting point again.
2026-07-06 14:52:39 -07:00
Saurav Panda ab08dea62c Fix markdown extraction destroying URLs and dropping long link lines
Two content-destruction bugs in extract_clean_markdown:

- A cleanup regex stripped every %XX sequence from the converted markdown,
  corrupting all percent-encoded URLs (%20, %2F, ...) — precisely when
  extract_links=True was requested.
- The JSON-blob line filter dropped any line over 100 chars starting with
  '{' OR '[' — silently deleting long markdown links [text](long-url),
  clickable images, and citation-style lines.

Delete the %XX regex, and only drop long lines that actually parse as JSON
(json.loads) so SPA state blobs are still filtered while markdown links
survive. Also extract the HTML->markdown conversion into a pure
convert_html_to_markdown() helper so this stage is unit-testable.
2026-07-06 14:45:25 -07:00
Saurav Panda b4b6868232 Handle same-document navigations without burning the readiness timeout
Page.navigate omits loaderId for same-document navigations (#fragment,
History API), and Chrome emits no new load/DOMContentLoaded lifecycle events
for them — the navigation is already committed when Page.navigate returns.
The stale-event timestamp guard would otherwise reject all buffered events
and burn the full readiness timeout.

Short-circuit when loaderId is absent, and simplify the stale-event guard
(the no-navigation-id case can no longer reach it). Regression test drains
the previous load's trailing networkIdle first so a stale event can't
accidentally satisfy the wait.
2026-07-04 04:27:18 +08:00
Saurav Panda c5f0fa767c Fix navigation readiness detection: per-target lifecycle event storage
Navigation waits polled a per-session event deque whose feeding handler was
registered per-session on cdp-use's single-slot event registry. Any later
target attach replaced the handler, freezing existing tabs' deques with only
pre-navigation events, so every navigation on those tabs burned the full
readiness timeout (3s same-domain / 8s cross-domain) and then proceeded on a
page in unknown load state.

- Store lifecycle events per target_id in SessionManager, fed by ONE global
  Page.lifecycleEvent handler registered in start_monitoring() and routed by
  session_id; buffers are freed on target removal
- _navigate_and_wait reads the per-target buffer and now returns a timeout
  status string instead of swallowing readiness timeouts;
  on_NavigateToUrlEvent surfaces it via NavigationCompleteEvent.loading_status
- Skip loaderId-less lifecycle events that predate the current navigation
- Drop unused CDPSession._lifecycle_lock

Deterministic regression test: navigating tab A after opening tab B took
exactly the 3s fallback timeout before this fix, <0.5s after.
2026-07-03 22:48:20 +08:00
Laith Weinberger 4e57863c26 fix skill install opencode overwrite 2026-07-01 21:44:26 +08:00
Laith Weinberger 76a2a0704b fix CLI telemetry debug stderr 2026-07-01 21:35:25 +08:00
Laith Weinberger e7f60fd589 update skill 2026-07-01 20:25:02 +08:00
Laith Weinberger 47227e63ff fix skill install targets, and sync harness docs 2026-07-01 20:05:52 +08:00
Laith Weinberger 4c13e28301 fix Browser Use CLI skill install and telemetry edge cases 2026-07-01 19:28:05 +08:00
Laith Weinberger 44f017fbc2 telemetry, fix issues
docs: remove rust; skills.sh install cmd
2026-07-01 17:57:24 +08:00
Laith Weinberger 3ed95c8b9c fix browser-use skill sync 2026-07-01 11:48:19 +08:00
Laith Weinberger d73eea6329 sync browser-use skill from browser-harness 2026-06-29 15:20:21 +08:00
Laith Weinberger 53c3ba2e72 Fix browser use CLI review issues 2026-06-29 14:00:13 +08:00
Laith Weinberger f768a06cfe new browser use CLI; new functions for deleted CLI methods 2026-06-29 13:10:55 +08:00
Laith Weinberger bfaad696bf remove old CLI 2026-06-29 13:00:44 +08:00
Laith Weinberger d5338ec208 Check skill install path ancestors 2026-06-29 10:58:38 +08:00
Laith Weinberger f197139aec Validate skill install destination first 2026-06-29 10:55:31 +08:00
Laith Weinberger c8e386959d Overwrite browser-use skill installs 2026-06-29 10:52:50 +08:00
Laith Weinberger e4ceae8d8e Wrap browser-harness skill install 2026-06-29 10:18:12 +08:00
laithrw 1e2799288d Merge branch 'main' into browser-use-skill-harness 2026-06-29 09:57:37 +08:00
Laith Weinberger 3e8f620b70 add browser-use skill backed by browser-harness 2026-06-29 09:42:26 +08:00
Saurav Panda 5123e4fc08 style: tighten ResilientEventBus docstring and comments 2026-06-26 15:56:17 +08:00