Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Pass available files to Rust agent
Magnus Müller796befe2ca9d
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex b585a5212..4eac35383 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -65,10 +65,15 @@ Terminal core branch: `magnus/browser-use-rust-integration` at latest pulled mai- The transcript includes task/session metadata, final result, errors, URLs, token usage, stdout/stderr, and raw terminal events.- Proof: `test_rust_agent_saves_terminal_conversation`.+12. Available file path context+ - `available_file_paths` are now passed into the Rust terminal task as concise local-file context.+ - This preserves the Browser Use constructor argument and gives the Rust core enough information to inspect user-provided files when needed.+ - Proof: `test_rust_agent_adds_available_files_to_task_context`.+## Current Verification- `python3 -m py_compile browser_use/rust/service.py browser_use/rust/__init__.py browser_use/__init__.py tests/ci/test_rust_agent.py examples/rust_agent/basic.py examples/rust_agent/real_v8_smoke.py`-- `uv run pytest -q tests/ci/test_rust_agent.py` (19 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (20 tests)- `cargo build -q -p browser-use-cli`- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-agent selected_remote_cdp_mode_allows_remote_cdp_connect -- --nocapture`- Managed-headless end-to-end:diff --git a/browser_use/rust/service.py b/browser_use/rust/service.pyindex e8e24fbe8..415857d0d 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -111,6 +111,13 @@ def _task_with_schema(task: str, output_model_schema: type[BaseModel] | None) ->return f'{task}\n\nExpected output JSON schema for the final answer:\n{schema}'+def _task_with_available_files(task: str, available_file_paths: list[str] | None) -> str:+ if not available_file_paths:+ return task+ files = '\n'.join(f'- {Path(path).expanduser()}' for path in available_file_paths)+ return f'{task}\n\nAvailable local files:\n{files}'++def _extract_start_url(task: str) -> str | None:task_without_emails = re.sub(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b', '', task)patterns = [@@ -439,7 +446,10 @@ class Agent(Generic[AgentStructuredOutput]):if self.initial_url:initial_actions = [{'navigate': {'url': self.initial_url, 'new_tab': False}}]self.initial_actions = initial_actions- self.task = _task_with_schema(_task_with_initial_navigation(task, initial_actions), output_model_schema)+ self.task = _task_with_schema(+ _task_with_available_files(_task_with_initial_navigation(task, initial_actions), self.available_file_paths),+ output_model_schema,+ )self.session_id: str | None = Noneself.history: AgentHistoryList[AgentStructuredOutput] = AgentHistoryList(history=[], usage=None)self.result: AgentHistoryList[AgentStructuredOutput] | None = Nonediff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex 47cf50c8d..3162d55ba 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -170,6 +170,20 @@ def test_rust_agent_exposes_browser_use_settings():assert agent.include_recent_events is True+def test_rust_agent_adds_available_files_to_task_context():+ from browser_use.rust import Agent++ agent = Agent(+ task='Summarize the provided report.',+ available_file_paths=['/tmp/report.txt', '~/notes.md'],+ )++ assert agent.available_file_paths == ['/tmp/report.txt', '~/notes.md']+ assert 'Available local files:' in agent.task+ assert '- /tmp/report.txt' in agent.task+ assert '- ' in agent.task and 'notes.md' in agent.task++def test_rust_agent_default_codex_model_matches_chatgpt_account(monkeypatch):from browser_use.rust import Agent