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
Reconstruct Rust terminal text artifact attachments
Magnus Müller3f2271630cb6
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex 1478cae39..b2acfe21e 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -719,10 +719,15 @@ Terminal core branch: `magnus/browser-use-rust-main-integration` at terminal mai- This preserves CLI/manual tool paths such as `python`, where `tool.started`, `tool.output`, and `tool.finished` can omit call ids, while explicit call-id matching still takes precedence and transient streaming chunks stay out of final action history.- Proof: `test_rust_history_reconstructs_terminal_unkeyed_tool_results`.+142. Rust terminal text-artifact attachment reconstruction+ - Terminal `tool.output` events with `text_artifact` now expose the spilled text artifact on Browser Use attachment surfaces.+ - This preserves current-main Python worker outputs that truncate large text in `text` while carrying the full artifact under `text_artifact`, including the synthesized final `done.files_to_display`.+ - Proof: `test_rust_history_reconstructs_terminal_text_artifact_attachments`.+## Current Verification- `python3 -m py_compile browser_use/agent/service.py 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` (113 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (114 tests)- `cargo build -q -p browser-use-cli` on terminal branch `magnus/browser-use-rust-main-integration`- `cargo test -q -p browser-use-cli run_codex_session_command_accepts_task_id_and_model -- --nocapture`- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-agent selected_remote_cdp_mode_allows_remote_cdp_connect -- --nocapture`diff --git a/browser_use/rust/service.py b/browser_use/rust/service.pyindex 0d8ecaabc..5d4f4b814 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -863,6 +863,9 @@ def _attachments_from_events(events: list[dict[str, Any]]) -> list[str] | None:if pointer:pointers.append(pointer)elif event_type in ('tool.output', 'tool.failed'):+ text_artifact = _artifact_attachment_pointer(payload.get('text_artifact'))+ if text_artifact:+ pointers.append(text_artifact)artifacts = payload.get('artifacts')if isinstance(artifacts, list):for artifact in artifacts:diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex 225745d6e..8aa5a1ca9 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -1299,6 +1299,53 @@ def test_rust_history_reconstructs_terminal_artifact_attachments():}+def test_rust_history_reconstructs_terminal_text_artifact_attachments():+ from browser_use.rust.service import _history_from_events++ history = _history_from_events(+ [+ {+ 'type': 'tool.started',+ 'payload': {+ 'name': 'python',+ 'arguments': {'code': "print('large report')"},+ },+ },+ {+ 'type': 'tool.output',+ 'payload': {+ 'name': 'python',+ 'ok': True,+ 'text': 'large report...',+ 'text_truncated': True,+ 'text_artifact': {+ 'artifact_id': 'tool-output-python-1234',+ 'path': '/tmp/artifacts/session/tool-output-python-1234.txt',+ 'file_name': 'tool-output-python-1234.txt',+ 'bytes': 8192,+ 'preview': 'large report...',+ 'token_budget': 2048,+ },+ },+ },+ {'event_type': 'session.done', 'payload': {'result': 'Generated large report.'}},+ ],+ model='gpt-test',+ started=1.0,+ finished=2.0,+ output_model_schema=None,+ process_error=None,+ )++ attachments = ['/tmp/artifacts/session/tool-output-python-1234.txt']++ assert history.action_history()[0][0]['result'] == 'large report...'+ assert history.action_results()[-1].attachments == attachments+ assert history.last_action() == {+ 'done': {'text': 'Generated large report.', 'success': True, 'files_to_display': attachments}+ }++def test_rust_agent_translates_browser_use_args_to_terminal(monkeypatch):from browser_use.rust import Agent