Commit Graph

6010 Commits

Author SHA1 Message Date
Magnus Müller
01acf052cd Remove recovery_attempted attribute from AgentState model to streamline state management. 2025-09-04 17:33:41 -07:00
Magnus Müller
c54b4efab5 Spelling 2025-09-04 17:32:37 -07:00
Magnus Müller
4460a8b7cb Update failure handling logic in Agent class to account for final response after failure. Adjusted logging messages for clarity and improved failure threshold checks. 2025-09-04 17:32:15 -07:00
Magnus Müller
f474e24b28 force-llm-output-after-failure 2025-09-04 17:22:32 -07:00
Magnus Müller
bf85863577 fix-popup-handling (#2956)
Auto-generated PR for branch: fix-popup-handling
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Fixes JavaScript popup handling by auto-dismissing
alerts/confirm/prompts immediately via CDP across all frames. Simplifies
the flow to prevent crashes and focus issues, and makes
DialogOpenedEvent.frame_id optional for missing CDP frameIds.

- **Bug Fixes**
- Register Page.javascriptDialogOpening on both session and root CDP
clients to catch dialogs from any frame.
- Dismiss dialogs with Page.handleJavaScriptDialog using session
fallbacks (detected session → agent focus) with short timeouts.
- PopupsWatchdog no longer listens to or emits DialogOpenedEvent; it
only listens to TabCreatedEvent.

- **Migration**
- If you relied on DialogOpenedEvent from PopupsWatchdog, remove those
listeners; dialogs are now dismissed silently.
- DialogOpenedEvent.frame_id is now optional (can be None); update any
strict type checks.

<!-- End of auto-generated description by cubic. -->
2025-09-04 16:41:38 -07:00
Magnus Müller
770955e0b0 Update PopupsWatchdog to automatically accept JavaScript dialogs instead of dismissing them. Adjust logging messages accordingly and remove unused post-dialog recovery method. 2025-09-04 16:32:37 -07:00
Magnus Müller
3a7ae8d8d6 popup works 2025-09-04 16:07:05 -07:00
Magnus Müller
6cbc0ade47 hooks-update (#2953)
Auto-generated PR for branch: hooks-update
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Adds a new Lifecycle Hooks docs page that explains on_step_start and
on_step_end with working examples and what agent data is available.
Updates docs navigation and adds a redirect from /development/hooks to
/customize/hooks.

<!-- End of auto-generated description by cubic. -->
2025-09-04 08:51:05 -07:00
Magnus Müller
f06a021b66 linter 2025-09-04 08:47:29 -07:00
Magnus Müller
2a3666d23a Add redirect for old hooks link 2025-09-04 08:43:15 -07:00
Magnus Müller
54c7806143 Merge branch 'main' into docs/hooks-update 2025-09-04 08:16:16 -07:00
Magnus Müller
1c269fffe7 Clean up hooks 2025-09-04 08:14:43 -07:00
Magnus Müller
b72ac61efb fix-system-prompt-for-new-interactive-elements (#2952)
Auto-generated PR for: fix-system-prompt-for-new-interactive-elements
2025-09-04 07:56:11 -07:00
Magnus Müller
9c6e3371fd fix-system-prompt-for-new-interactive-elements 2025-09-04 07:55:52 -07:00
Magnus Müller
eda4383ee9 remove lmnr from examples (#2946)
Auto-generated PR for: remove lmnr from examples
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Removed Laminar from example scripts and a test to reduce setup friction
and prevent unintended instrumentation. Updated docs to show how to
disable Browser Use instrumentation, and bumped lmnr to 0.7.10 for
dev/eval.

- **Refactors**
- Removed lmnr imports/initialize from example scripts and the Gemini
image test.
  - Examples now rely only on browser_use and their respective LLM SDKs.
- Docs: Laminar.initialize now shows
disabled_instruments={Instruments.BROWSER_USE}.

- **Dependencies**
  - Updated lmnr[all] to 0.7.10 in eval and dev dependencies.

<!-- End of auto-generated description by cubic. -->
2025-09-03 18:15:26 -07:00
Magnus Müller
dc1eb696b3 remove lmnr from examples 2025-09-03 18:11:45 -07:00
Magnus Müller
e2b84909bd dont wait 10 seconds if allowed_domains not set (#2942)
Auto-generated PR for: dont wait 10 seconds if allowed_domains not set
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Remove the 10-second pause when allowed_domains is not set. We now log a
concise warning and continue without blocking; the message is simplified
and the interactive prompt was removed.

<!-- End of auto-generated description by cubic. -->
2025-09-03 15:23:34 -07:00
Magnus Müller
8177a2c586 Merge branch 'main' into dont-wait-10-seconds-if-alloweddomains-not-set 2025-09-03 15:23:27 -07:00
Magnus Müller
e1a6796e92 fix-pil-import (#2943)
Auto-generated PR for: fix-pil-import
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Fixes PIL import errors and makes screenshot highlighting more robust by
adding Pillow as a runtime dependency and using cross-platform font
loading with caching to prevent crashes and memory leaks.

- **Bug Fixes**
- Added a cached, cross-platform font loader to avoid OSError on missing
fonts.
- Explicitly close image buffers and force GC to prevent memory leaks in
long runs.
  - Exported cleanup_font_cache for external use.

- **Dependencies**
- Moved pillow>=11.2.1 to runtime dependencies and removed it from
dev-only deps.

<!-- End of auto-generated description by cubic. -->
2025-09-03 15:22:32 -07:00
Magnus Müller
2bb18c899c Remove unused observability decorator from detect_display_configuration method in profile.py 2025-09-03 15:22:15 -07:00
Magnus Müller
e7897a90d9 Remove overlays 2025-09-03 15:14:18 -07:00
Magnus Müller
4f891cd5f6 Remove gc 2025-09-03 15:14:00 -07:00
Magnus Müller
2a2ed2813f Remove duplicate 2025-09-03 14:29:33 -07:00
Magnus Müller
198f343c6a Refactor type hint for font cache and function return type in python_highlights.py
Updated the type hint for the _FONT_CACHE dictionary to use a union type for better clarity. Modified the return type of get_cross_platform_font function to reflect the same change, enhancing type safety and readability.
2025-09-03 14:21:19 -07:00
Magnus Müller
53e5858d8e fix-pil-import 2025-09-03 14:19:23 -07:00
Magnus Müller
c7cbcadc74 Merge branch 'dont-wait-10-seconds-if-alloweddomains-not-set' of https://github.com/browser-use/browser-use into dont-wait-10-seconds-if-alloweddomains-not-set 2025-09-03 14:10:18 -07:00
Magnus Müller
b1531533d3 Update test for new wait parameter 2025-09-03 14:10:16 -07:00
Magnus Müller
73fa1c2d10 Merge branch 'main' into dont-wait-10-seconds-if-alloweddomains-not-set 2025-09-03 13:58:18 -07:00
Magnus Müller
4ccaf27df6 Update maximum wait time to 30 sec 2025-09-03 13:58:04 -07:00
Magnus Müller
601cfc3e23 dont wait 10 seconds if allowed_domains not set 2025-09-03 13:54:29 -07:00
Magnus Müller
2d84ff6605 Add sample_images to enable browseruse to learn how to operate a plat… (#2910)
…form.
When setting up task in browseruse, add a parameter for annotating
images, enabling browseruse to recognize some interactive components on
web pages.
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Add optional sample_images to Agent and message flow to include
annotated example images in the vision prompt, helping the agent
recognize interactive UI components. When provided, these images are
inserted before screenshots; behavior is unchanged if omitted.

- **New Features**
  - Agent and MessageManager accept sample_images.
- Prompts inject sample_images into the user message ahead of
screenshots.
  - Defaults to None for backward compatibility.

<!-- End of auto-generated description by cubic. -->
2025-09-03 11:10:06 -07:00
Magnus Müller
82566c3efd Delete browser_use/agent/system_prompt_sample.md 2025-09-03 11:09:01 -07:00
Magnus Müller
23b5a2b8d4 Merge branch 'main' into feature/sample_images 2025-09-03 11:06:50 -07:00
Magnus Müller
2e1d0f954f fix gemini example (#2940)
Auto-generated PR for: fix gemini example
2025-09-03 11:06:00 -07:00
Magnus Müller
d13cedbf5c fix gemini example 2025-09-03 11:05:42 -07:00
Magnus Müller
2bd3a14960 Fix patterns in allowed_domains (#2917)
This will make "https://www.example.com" match "https://*.example.com",
which is currently no longer the case.

Also, update the "exact match" logic to match the logic used in pattern
matching.

A new test has been added to prevent regresssions.
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Fixes allowed_domains pattern matching so scheme-based wildcards (e.g.,
https://*.example.com) correctly match full URLs (e.g.,
https://www.example.com). Also aligns exact match detection with pattern
logic.

- **Bug Fixes**
- Use fnmatch on the full URL when the pattern includes a scheme (://),
restoring matches like https://www.example.com against
https://*.example.com.
- Replace hardcoded scheme checks with ':// in pattern' for exact
matches to keep behavior consistent across schemes.

<!-- End of auto-generated description by cubic. -->
2025-09-03 11:04:04 -07:00
Magnus Müller
00fd2e8a99 Merge branch 'main' into fix-allowed-urls-patterns 2025-09-03 11:01:25 -07:00
Magnus Müller
73445c4245 chore: relax major LLM lib version constraints (#2936)
Currently, the major LLM lib constraints are very limiting. In my
project it is causing a ton of clashes with other popular LLM libraries
such as `pydantic-ai`, for example. I imagine a lot of `browser-use`
users are experiencing the same troubles.
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Relaxed major version pins for google-genai, openai, and anthropic to
allow minor/patch updates while blocking breaking majors. This reduces
dependency conflicts and improves install compatibility with other LLM
libraries.

- **Dependencies**
  - google-genai: >=1.29.0,<2.0.0
  - openai: >=1.99.2,<2.0.0
  - anthropic: >=0.58.2,<1.0.0

<!-- End of auto-generated description by cubic. -->
2025-09-03 11:00:57 -07:00
Magnus Müller
eec96f6b95 Merge branch 'main' into chore/relax-major-llm-lib-versions 2025-09-03 10:53:52 -07:00
Magnus Müller
ff422da6df remove test self hosted (#2939)
Auto-generated PR for: remove test self hosted
2025-09-03 10:52:54 -07:00
Magnus Müller
a0ffb70b01 remove test self hosted 2025-09-03 10:52:36 -07:00
Magnus Müller
419f558629 fix-wildcard-imports (#2938)
Auto-generated PR for: fix-wildcard-imports
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Replaced wildcard imports in browser_use.llm with lazy, typed model
access to reduce import overhead and improve IDE autocomplete while
keeping the API unchanged. Also reordered imports in the agentmail
example so env vars load before module imports.

- **Refactors**
- Removed from browser_use.llm.__init__ import *. Implemented
__getattr__ to proxy model names from browser_use.llm.models with
caching.
- Kept lazy imports for chat backends and added a clean cache for model
instances to avoid re-instantiation.
  - Added type stubs for common model instances to improve editor hints.
- Moved imports in examples/integrations/agentmail/2fa.py below
load_dotenv to ensure correct env loading.

<!-- End of auto-generated description by cubic. -->
2025-09-03 10:48:21 -07:00
Magnus Müller
b87657dd22 Enhance error handling in __getattr__ to catch ImportError in addition to AttributeError for improved robustness. 2025-09-03 10:47:30 -07:00
Magnus Müller
e26eceb7fc fix-wildcard-imports 2025-09-03 10:38:42 -07:00
Magnus Müller
12dcdab044 update-default-llm-andagent-mail (#2937)
Auto-generated PR for branch: update-agent-mail-example
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Adds a simple models interface for choosing LLMs and lets Agent
auto-select a default LLM via the DEFAULT_LLM env var. Updates the
AgentMail 2FA example and lowers max_actions_per_step to 4.

- **New Features**
- New models module for easy model access (e.g.,
models.azure_gpt_4_1_mini) and get_llm_by_name().
- Agent accepts llm=None and loads DEFAULT_LLM from env, falling back to
gpt-4.1-mini.
  - Added DEFAULT_LLM to config/FlatEnvConfig.

- **Refactors**
- Replaced EmailController with EmailTools (supports injected inbox);
updated 2FA example to use AsyncAgentMail, models, and explicit Browser
path.
  - Added lazy import example (examples/models/lazy_import.py).
  - Reduced AgentSettings.max_actions_per_step default from 10 to 4.

<!-- End of auto-generated description by cubic. -->
2025-09-03 10:01:06 -07:00
Magnus Müller
2bbd452a39 Merge branch 'main' into update-agent-mail-example 2025-09-03 09:56:49 -07:00
Magnus Müller
0a646cb125 change parameter chat google (#2930)
Auto-generated PR for: change parameter chat google
    
<!-- This is an auto-generated description by cubic. -->
---

## Summary by cubic
Aligns Google chat model defaults with OpenAI and adds output token
control for more predictable behavior across providers.

- **New Features**
- Set default temperature to 0.2 and add max_output_tokens (default
4096).
  - Pass max_output_tokens to the GenerateContent config in ainvoke.

- **Dependencies**
  - Add pydantic_settings>=2.10.1 to dev dependencies.

<!-- End of auto-generated description by cubic. -->
2025-09-03 09:55:54 -07:00
Magnus Müller
10b4acc9ad Merge branch 'main' into change-parameter-chat-google 2025-09-03 09:55:31 -07:00
Magnus Müller
15054a75c9 Update max_actions_per_step to 4 2025-09-03 09:51:36 -07:00
Magnus Müller
8cbf2ff7e1 Update prompt 2025-09-03 09:51:23 -07:00