Commit Graph

213 Commits

Author SHA1 Message Date
mertunsall 2c465a898a - Introduce a max_history_items parameter to limit the memory of the model
- changed the system messages to have <sys> tag instead of <s> to avoid confusion with HTML
-  Got rid of MessageMetadata, SupportedMessageTypes and implemented cleaner MessageManagerState
- Implemented a HistoryItem class to cleanly reconstruct agent history description
2025-07-01 12:04:27 +02:00
Gregor Žunič 2c884040c4 Merge branch 'main' into gregor/eng-238-fix-token-counts-on-eval-platform 2025-06-29 19:40:29 +02:00
Gregor Žunič d7c8dc99a8 Update browser_use/agent/views.py
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
2025-06-29 19:36:43 +02:00
Gregor Žunič 48ae2d19cf much better structured output + utils for generating pydantic schema 2025-06-29 17:42:19 +02:00
Gregor Žunič 0691500c6a wip 2025-06-29 16:22:19 +02:00
Gregor Žunič b37e026f89 added usage data to agent history and evals 2025-06-29 11:28:20 +02:00
Nick Sweeting 747959a3d0 keep reference to the original browser session when copying 2025-06-26 22:45:05 -07:00
Gregor Žunič 35bb5e8039 Add token caching for claude (#2108)
<!-- This is an auto-generated description by cubic. -->

## Summary by cubic
Added token caching support for Claude models, including accurate
tracking and cost calculation for cached, cache creation, and uncached
tokens.

- **New Features**
- Added `cache` flag to messages and updated Anthropic message
serialization to support Claude's token caching.
- Updated token usage and cost tracking to handle cached tokens, cache
creation tokens, and their costs.
- Improved token usage logs to show detailed breakdowns for cached and
uncached tokens.
  - Added tests for Anthropic cache serialization and cost calculation.

<!-- End of auto-generated description by cubic. -->
2025-06-25 21:28:42 +02:00
Gregor Žunič 2ee526d903 updated pricing for cached tokens support 2025-06-25 15:33:47 +02:00
mertunsall fa60e747d9 mr cloudrunner 2025-06-24 23:02:08 +02:00
mertunsall 763d3f13ef fix format? 2025-06-24 18:20:46 +02:00
mertunsall d6af0ef7b4 format? 2025-06-24 18:17:26 +02:00
mertunsall 06e092f9d1 fix 2025-06-24 18:06:46 +02:00
mertunsall e6dfee739d fix bugs 2025-06-24 17:08:07 +02:00
Cursor Agent 7f369df0c8 Fix type hints and improve type safety in AgentOutput and service module 2025-06-24 14:48:16 +00:00
mertunsall b3e83d6d05 Fix 2025-06-24 16:39:14 +02:00
Cursor Agent d57850639b Make thinking field optional in browser-use agent 2025-06-24 12:40:07 +00:00
Gregor Žunič 7a10ae0c96 Squashed commit langchain to native 2025-06-24 12:26:55 +02:00
mertunsall 9ae6354b76 - Change reasoning rules in system prompt
- Flatten AgentOutput to get rid of current_state
- Add agent initialization in history.
- Update the example tool call.
- Add a current_state property to AgentOutput for compatibility.
2025-06-20 18:55:04 +02:00
Magnus Müller 90ae26316e Refactor ActionResult to standardize the inclusion of extracted content, replacing update_only_read_state with include_extracted_content_only_once across multiple services. This change enhances clarity in memory management and ensures consistent handling of extracted content. 2025-06-19 23:18:30 +02:00
Magnus Müller ce880e5e35 Refactor ActionResult handling across multiple services to standardize the use of long_term_memory, replacing memory references. Update related logic to ensure extracted content is consistently managed for improved clarity and error handling. 2025-06-19 23:11:55 +02:00
mertunsall 129590672d small update to descriptions 2025-06-19 14:09:06 +02:00
Magnus Müller 0b6ebea431 Merge branch 'main' into mert/new_everything 2025-06-19 09:49:43 +02:00
mertunsall bbc8d26f63 - Updated ActionResult to include an attachments field for displaying files in the done message.
- Enhanced logging in the Agent class to inform users about available attachments after task completion.
- Revised system prompt guidelines to clarify the use of text and files_to_display in the done action.
2025-06-18 14:24:27 +02:00
Nick Sweeting d0ec528802 fixed events 2025-06-17 22:38:59 -07:00
mertunsall 0c34c399db Merge branch 'main' into mert/new_everything 2025-06-17 11:19:06 +02:00
Nick Sweeting 582c039c15 make save_context and other file operations async, setup traces and other dirs on startup 2025-06-12 18:38:12 -07:00
Magnus Müller 52d4191ba9 Merge branch 'main' into mert/new_everything 2025-06-07 17:58:09 +02:00
Nick Sweeting 3c1e2a59d1 remove save_playwright_script_path entirely 2025-06-05 02:06:23 -07:00
mertunsall bcdc522ade Nuke it all 2025-05-31 17:30:21 +02:00
Nick Sweeting 75f14c4784 checkpoint 2025-05-24 20:41:44 -07:00
Nick Sweeting 90dad4a39a refactor to use new BrowserSession model 2025-05-17 04:54:13 -07:00
Nick Sweeting 3e66046046 linter 2025-05-13 17:18:50 -07:00
Nick Sweeting 2b71f33f7e Support Azure OpenAI API GPT-4 (#1532) 2025-05-02 09:58:20 -07:00
Nick Sweeting 66b3c26df5 add pyupgrade to lint rules 2025-05-02 15:21:23 +08:00
Max Comperatore 9289e0f7f2 Support Azure OpenAI API GPT-4 2025-05-01 14:09:43 +00:00
RogelioRichmanAstronaut 0e5c676504 fix: Apply pre-commit linting fixes and improve Playwright example script execution
- Applied automated linting suggestions from pre-commit hooks, primarily updating type hints (e.g., Dict -> dict) and organizing imports.
- Refactored Playwright script execution in examples/features/playwright_script_generation.py to use asyncio.create_subprocess_exec for asynchronous handling and real-time log streaming, resolving ASYNC221 lint error and improving output visibility.
2025-04-30 00:05:36 -05:00
RogelioRichmanAstronaut c7fbc7e071 Chore: Remove unnecessary LLM comments
Remove comments automatically added by the LLM in agent-related files.

Removed comments from:
- browser_use/agent/playwright_script_generator.py
- browser_use/agent/service.py
- browser_use/agent/views.py

These comments were redundant and cluttered the code.
2025-04-29 20:23:44 -05:00
Nick Sweeting 51f09b85aa Merge branch 'main' into feat/playwright-script-generation 2025-04-28 20:11:41 -07:00
Nick Sweeting 85586ef821 Merge branch 'main' into mathisarends-viadee/extend-system-prompt-for-planner-llm 2025-04-21 11:03:05 -07:00
Nick Sweeting 8b165d5997 fix ruff errors in other files 2025-04-21 10:56:06 -07:00
Nick Sweeting 738508d413 Merge branch 'main' into mathisarends-viadee/extend-system-prompt-for-planner-llm 2025-04-21 10:17:33 -07:00
Nick Sweeting 2b4397f1b8 Merge pull request #1417 from qkfang/azureopenai_env 2025-04-21 10:11:28 -07:00
RogelioRichmanAstronaut 71400d93e6 feat: Add Playwright script generation from agent history
Implement the ability to generate executable Playwright scripts from an Agent's run history (`AgentHistoryList`).

This introduces the `PlaywrightScriptGenerator` class which translates recorded agent actions (clicks, inputs, navigation, etc.) into a Python script using Playwright's async API.

Key features:
- Uses XPath selectors derived from the agent's interaction history.
- Includes a robust helper function (`_try_locate_and_act`) with XPath prefix trimming for improved resilience on dynamic pages.
- Handles sensitive data placeholders by mapping them to environment variables in the generated script.
- Supports configuring the browser launch and context based on the original agent's `BrowserConfig` and `BrowserContextConfig`.
- Activated by setting the `save_playwright_script_path` option in `AgentSettings`.

Includes modifications to `Agent` service to trigger generation and `AgentHistoryList` view to add the saving method. Also adds a new example (`examples/features/playwright_script_generation.py`).

This feature enables reliable replay of agent runs, automated testing, and scripting of repetitive tasks discovered by the agent.
2025-04-21 11:05:06 -05:00
Daniel Fang 3657f0a3f5 Update views.py 2025-04-18 16:33:37 +10:00
Dev-Khant 52ac120e94 Merge branch 'main' into fix-huggingface-issue 2025-04-17 13:38:18 +05:30
Dev-Khant c4ea195ae4 address comments 2025-04-17 13:35:26 +05:30
Dha-aa 7ca46f22c2 Run ruff fix and format on modified files 2025-04-16 11:46:58 +05:30
Dha-aa 27525a8595 Add GROK_API_KEY to REQUIRED_LLM_API_ENV_VARS in agent/views.py 2025-04-16 10:52:28 +05:30
mathisarends-viadee 075d776bb3 Add extend function for planning system prompt 2025-04-14 09:27:31 +02:00