Commit Graph

1537 Commits

Author SHA1 Message Date
Saurav Panda 2afef14667 Trim comments to essentials 2026-07-06 16:47:27 -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 4cbc5dfa4d feat(llm): accept provider-prefixed models in ChatBrowserUse
ChatBrowserUse now accepts provider-prefixed model ids (anthropic/*,
openai/*, google/*) alongside the bu-* aliases and browser-use/* models,
so a single BROWSER_USE_API_KEY can reach them. bu-* aliases and the
bu-latest -> bu-2-0 normalization are unchanged; bare ids are rejected
with guidance toward the provider/model form.

Also matches provider-prefixed Claude Sonnet ids in the Agent
llm_screenshot_size auto-config, so the screenshot optimization isn't
lost when Claude is reached via ChatBrowserUse.

Adds an example, a README FAQ entry, and tests.

ENG-5060
2026-06-10 12:03:51 +05:30
Laith Weinberger 8bca742aba support claude fable 5
- fable for coord clicks
- explicit support
- model refusal response
- fable pricing with 5m/1h cache writes and inference geo multiplier
- anthropic fallback, thinking, output config, and inference geo request support
2026-06-09 13:22:04 -07:00
Gregor Žunič 7a888eb9a4 Promote beta core package quickstart 2026-06-08 12:59:51 -07:00
Magnus Müller 9400ba596d Fix Rust PR CI feedback 2026-06-06 05:20:57 +00:00
Magnus Müller e22b6fe5fc Fix Rust Agent wrapper initialization parity 2026-06-04 23:11:10 +00:00
Magnus Müller 1474c60da1 Merge remote-tracking branch 'upstream/main' into magnus/browser-use-rust-core-integration
# Conflicts:
#	browser_use/__init__.py
#	browser_use/agent/service.py
#	browser_use/browser/watchdogs/downloads_watchdog.py
#	browser_use/code_use/utils.py
#	browser_use/llm/models.py
#	browser_use/tokens/service.py
#	browser_use/utils.py
2026-06-04 16:14:57 +00:00
Magnus Müller 91705e22b7 Sanitize direct-start URL candidates 2026-06-04 08:51:39 +00:00
Magnus Müller f644efbcad Record Rust eval Laminar summaries 2026-06-04 04:10:20 +00:00
Magnus Müller 917988ec25 Preserve Python Agent default export 2026-06-03 17:45:34 +00:00
Magnus Müller fe84f1a5ce Match Rust agent runtime signatures 2026-06-03 07:31:51 +00:00
Magnus Müller 04d239946a Route agent service import to Rust agent 2026-06-03 06:13:28 +00:00
Magnus Müller ce864232d4 Export Rust agent from agent package 2026-06-02 21:29:33 +00:00
Magnus Müller 2384c3e951 Merge branch 'main' into fix/skip-new-tab-screenshots 2026-05-25 20:39:17 -07:00
MagMueller b727b36dcc fix(agent): skip screenshots on new tab pages 2026-05-25 20:38:12 -07:00
MagMueller 6c36054ae4 Pass session id to judge LLM calls 2026-05-25 14:05:48 -07:00
MagMueller 51598efd56 Trim HistoryItem freeze change tests 2026-05-23 12:20:55 -07:00
MagMueller 90a052371d Move user request before agent history 2026-05-23 09:48:15 -07:00
Saurav Panda b06b47a23a Merge branch 'main' into prompt-cache/relocate-per-step-metadata 2026-05-22 18:11:00 -07:00
Saurav Panda a3bae60ed2 agent(prompts): move per-step metadata out of <agent_state> into a tail block
The step counter (Step N maximum:M) and datetime.now() were rendered
inside <agent_state>, ahead of <browser_state> in the user message.
The cache miss already happens at the <agent_state> boundary today, so
this isn't a live cache regression — but the layout meant that any
future move of more-stable agent_state fields into the system prompt
would still leave per-step varying bytes in the middle of the prefix,
silently capping how far the cache could extend.

Pull both fields into a new _get_step_meta_description() and append it
at the very end of get_user_message(), after <agent_state>,
<browser_state>, <read_state>, <page_specific_actions>, and unavailable-
skills info. Everything above this tail block is now eligible to be
treated as the cacheable region.

Adds regression tests that lock the layout:
- <step_info> must appear after <agent_state> and <browser_state>
- <step_info> must not leak back into <agent_state>
- bytes before <step_info> must be identical across two different step
  numbers (the step counter must not be in the prefix)
2026-05-22 17:58:13 -07:00
Saurav Panda 8236cc7506 agent(history): freeze HistoryItem + lock byte-prefix property in tests
For Gemini's implicit cache (and similar provider caches) to actually
hit step over step, the rendered transcript for steps 1..N-1 must be
byte-identical at step N and at step N+1. The agent already appends
HistoryItems immutably in practice, but nothing in the type prevented
a future caller from mutating one in place — which would silently kill
the cache from that byte onward.

Mark HistoryItem frozen so any mutation now fails loud at runtime
rather than slowly burning input tokens. Add a regression test set
that asserts the cache property directly:

- render(items[:N]) must be a strict byte-prefix of render(items[:N+1])
- to_string() is deterministic for identical inputs
- the prefix property holds across mixed entry shapes (normal steps,
  errors, system messages, follow-up tasks)
- conditional field inclusion doesn't collapse to ambiguous output

Known limitation, not addressed here: max_history_items compaction in
MessageManager.agent_history_description rewrites earlier bytes once
the cap is exceeded (the omitted-count message changes). That's a
larger redesign and deserves its own PR.
2026-05-22 17:55:43 -07:00
Saurav Panda 54322e6a8b fix: correct except indentation and preserve connection-error handling
- Re-indent the except block to match the inner try (was a SyntaxError)
- Drop asyncio.CancelledError from the isinstance check (it's BaseException,
  never reaches except Exception)
- Re-raise on _is_connection_like_error so _handle_step_error can run its
  reconnect / browser-closed shutdown logic
- Include exception class name in the preserved ActionResult error
2026-05-02 17:59:04 -07:00
Tony fd7eeeb15f fix: re-raise control-flow exceptions (InterruptedError, CancelledError)
PHclaw pointed out that _check_stop_or_pause() raises InterruptedError
inside the multi_act loop. Converting it to an ActionResult would prevent
the agent from properly stopping/pausing between batched actions.

Re-raise InterruptedError and asyncio.CancelledError before wrapping
other exceptions as ActionResult with partial results.
2026-04-30 16:00:44 +08:00
Tony bca433ccb2 fix: preserve partial action results when mid-batch action fails
When multi_act() executes a batch of actions and one fails mid-way,
the partial results from successfully executed earlier actions were
discarded by re-raising the exception. The agent lost visibility into
which actions completed before the failure.

Return the accumulated results with an error ActionResult appended,
which aligns with the existing post_process logic that explicitly
handles multi-action errors via loop detection and replan nudges
(lines 1221-1222).
2026-04-30 16:00:44 +08:00
Saurav Panda a97ba48345 fix(agent): timeout _execute_initial_actions so empty-history hangs cannot happen
The main execution loop already wraps _execute_step with asyncio.wait_for
using settings.step_timeout (default 180s). But _execute_initial_actions,
which runs before the main loop, is unwrapped — if it hangs (e.g. the
first navigate stalls on a silent CDP WebSocket before the per-action
timeout can catch it), the agent blocks indefinitely without ever
entering the main loop. No step gets recorded, history stays empty, and
any outer watchdog eventually kills the run with zero diagnostic data.

Wrap _execute_initial_actions with the same step_timeout. On timeout,
record the failure in state.last_result / consecutive_failures and fall
through to the main execution loop so the agent can still attempt to
recover. InterruptedError (from an interrupting callback) is still
swallowed silently — same contract as before.

Paired with the per-action asyncio.wait_for added in tools/service.py,
this closes the last unprotected path in the pre-main-loop flow.
2026-04-20 16:39:22 -07:00
Laith Weinberger 65f87b7fca fix sensitive_data redaction order to prevent substring leaks 2026-04-11 18:16:24 -04:00
Alezander9 76569995fd Improve OSS-to-cloud conversion: UTM tracking, better error messages, and cloud nudges
- Add UTM params to all cloud-bound links across README, CLI, and error messages
- Rewrite README Open Source vs Cloud section: position cloud browsers as
  recommended pairing for OSS users, remove separate Use Both section
- Rewrite error messages for use_cloud=True and ChatBrowserUse() to clearly
  state what is wrong and what to do next
- Add missing URLs: invalid API key now links to key page, insufficient
  credits now links to billing page
- Add cloud browser nudge on captcha detection (logger.warning)
- Add cloud browser nudge on local browser launch failure
2026-04-08 22:05:50 -07:00
laithrw 6129ceb0b0 Merge branch 'main' into fix/agent-history-safe-access 2026-04-07 14:18:38 -04:00
laithrw 8fcbe9f2fa Merge branch 'main' into fix/step-timeout-counter-and-stale-history 2026-03-25 19:22:19 -04:00
laithrw 4f268e4390 Merge branch 'main' into override-price-config 2026-03-25 18:20:20 -04:00
laithrw 4f33289c48 Merge branch 'main' into clawoss/fix/signal-handler-opt-out-4385 2026-03-25 16:19:49 -04:00
Laith Weinberger 39b911398e fix load_from_dict and final_result crashing on incomplete history entries 2026-03-23 13:20:03 -04:00
matt-greathouse 1c5020050c feat(tokens): allow overriding model pricing URL 2026-03-23 07:52:48 -04:00
warren618 c0a11dc61e fix: move state clear to after _prepare_context per review feedback
_prepare_context passes last_model_output/last_result to the message
manager for the "previous action result" prompt section. Clearing
them before context preparation drops this context.

Move the clear to after _prepare_context but before _get_next_action,
so prompt assembly still sees the previous step's output while
preventing stale data on timeout during the LLM call or action phase.
2026-03-23 11:42:11 +08:00
warren618 909e80a1b3 fix(agent): prevent stale history and stuck step counter on timeout
Two related bugs when step() is cancelled by timeout:

1. step() does not clear last_model_output/last_result at the start,
   so if timeout occurs before _get_next_action, _finalize() sees
   stale values from the previous step and records a duplicate history
   entry with wrong step numbers.

2. _finalize() early-returns when last_result is falsy, skipping the
   n_steps increment. On timeout, this means the while loop retries
   the same step number repeatedly.

Fix: clear last_model_output and last_result at step() entry, and
ensure _execute_step increments n_steps after a timeout if _finalize
did not already do so.
2026-03-23 11:25:37 +08:00
r266-tech cf6a799d63 fix: prevent KeyError/IndexError in AgentHistoryList.load_from_dict and final_result
- load_from_dict: use data.get('history', []) and h.get() for safe access
  to avoid KeyError when history dict is missing keys (e.g. legacy/partial
  history files saved before a schema change)
- final_result: add len() check before accessing result[-1] to prevent
  IndexError when the result list is empty, consistent with is_done(),
  is_successful(), judgement() and other methods in the same class
2026-03-23 01:46:50 +08:00
Saurav Panda 6d86be3a6b fix: detect skeleton screens and retry navigation for blank SPA pages 2026-03-19 18:48:47 -07:00
Saurav Panda befc7155ad Merge branch 'main' into fix-done-action-hallucination 2026-03-18 18:08:01 -07:00
Saurav Panda cb75bf846a Merge branch 'main' into fix-compaction-hallucination 2026-03-18 17:54:14 -07:00
Saurav Panda 42e9c101fd Update browser_use/agent/system_prompts/system_prompt_flash.md
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2026-03-18 17:51:54 -07:00
Saurav Panda 70ced22b7b fixed system prompt for data grounding 2026-03-18 17:39:17 -07:00
Saurav Panda cc3cc8fea7 Merge branch 'main' into fix-done-action-hallucination 2026-03-18 16:11:31 -07:00
Saurav Panda 179d526786 added better data grounding in done action 2026-03-18 16:08:00 -07:00
Saurav Panda 653d795f15 changed default compaction to 25 steps 2026-03-17 17:17:20 -07:00
Saurav Panda 0dea9480ee Merge branch 'main' into fix-compaction-hallucination 2026-03-17 15:43:11 -07:00
Saurav Panda 02349f1d9c fix: prevent compaction hallucination 2026-03-17 15:39:35 -07:00
BillionClaw 1147daef92 fix(utils): add option to disable SignalHandler for host app signal control
Add disabled parameter to SignalHandler class to allow opting out of
signal handling. This enables browser-use to be embedded in applications
like uvicorn/FastAPI that need to manage their own signal lifecycle.

Add enable_signal_handler parameter to Agent class (default True for
backward compatibility). When set to False, the Agent will not register
signal handlers, allowing the host application to control graceful
shutdown and signal handling.

Fixes #4385
2026-03-17 09:59:49 +08:00
Saurav Panda 8044181443 Merge branch 'remove-read-long-content-action' of https://github.com/browser-use/browser-use into remove-read-long-content-action 2026-03-12 12:56:48 -07:00
Saurav Panda b3ea4d82b7 Fix prompt guidance for find_elements 2026-03-12 12:56:36 -07:00