Skip to content

Feature/pip-package - #4

Merged
gregpr07 merged 3 commits into
mainfrom
feature/pip-package
Nov 6, 2024
Merged

gregpr07 merged 3 commits into
mainfrom
feature/pip-package

Conversation

@gregpr07

@gregpr07 gregpr07 commented Nov 6, 2024

Copy link
Copy Markdown
Member

Create a pypi package that people can download

@gregpr07
gregpr07 merged commit 77b5a99 into main Nov 6, 2024
@gregpr07
gregpr07 deleted the feature/pip-package branch November 6, 2024 17:58
MagMueller pushed a commit that referenced this pull request Nov 15, 2024
rexvel pushed a commit to rexvel/browser-use that referenced this pull request Jan 24, 2025
az-rye pushed a commit to rye-com/browser-use that referenced this pull request Aug 8, 2025
making fallback agent prompt better
clearclown added a commit to clearclown/browser-use-automation that referenced this pull request Oct 16, 2025
## 実験内容

HTLLアーキテクチャ(Apache Kafka, Druid, Flink)を用いた
Autonomous Intersection Management (AIM) の有用性検証のための
先行研究収集実験。

## 検索キーワード & 収集件数

1. Autonomous Intersection Management → 10件
2. Real-time Big Data Vehicular Traffic → 10件
3. V2X Vehicular Communication → 10件
4. Apache Kafka Druid → 1件
5. High Throughput Low Latency → 10件 (Kafka含む)
6. Apache Flink Stream Processing → 10件 (Kafka+Flink含む)
7. Vehicle Collision Avoidance → 10件

**合計: 62件の先行研究**

## 成果物

### `RESEARCH_SUMMARY_AIM_HTLL.md` (約10,000語)
- AIMの有用性に関する文献レビュー
- HTLL (Kafka/Flink/Druid) + AIM統合の先行研究
- 研究ギャップと独自性の分析
- 必読論文リスト(優先度付き)
- 実装参考文献の整理

### 主要な発見

**AIM基礎文献:**
- browser-use#3: Reservation-based AIM (予約ベース + 車両故障対応)
- browser-use#6: Graph Coloring (衝突検知、タイル分け類似)
- browser-use#4: 4-way AIM Algorithm (4又交差点)

**HTLL + AIM統合:**
- browser-use#12: Kafka + Flink + ML (ハイブリッドアプローチ)
- browser-use#13: Automobile Data + Kafka + Flink (車両特化)
- browser-use#19: Real-Time Pipeline for Autonomous Control

**研究の独自性:**
- AIM + HTLL(Kafka/Druid/Flink)の統合研究は少ない
- 特にDruid含む3要素の組み合わせは新規性が高い
- 二重のベースライン比較(信号機 vs AIM, RDB vs HTLL)

## データベース

全検索結果はJSON形式で保存:
- `search_results_*.json` (15ファイル)
- 各論文のタイトル、著者、URLを含む

## ツール

- Browser-Use Automation + IEEE Xplore Integration
- LLMプロバイダー: DeepSeek (deepseek-chat)
- 自動スクロール & メタデータ抽出

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
sauravpanda added a commit that referenced this pull request May 23, 2026
## Context

Closes part of #4887 (item #4 — explicit CachedContent support).

Gemini's implicit context cache is great for the steady-state of an
agent loop but has a ~5-minute TTL and is per-call best-effort. For long
sessions (or sessions that go quiet for >5 minutes and resume), explicit
`CachedContent` is the deterministic alternative: you create a named
cache once with the prefix, then reference it on subsequent calls and
Google bills the cached portion at the discounted rate, period.

The wrapper in `browser_use/llm/google/chat.py` already parses
`cached_content_token_count` out of `response.usage_metadata` into
`ChatInvokeUsage.prompt_cached_tokens`, so the savings are visible — it
just had no way to *send* a cache reference.

## Change

- New `cached_content: str | None = None` field on `ChatGoogle`.
- New `cached_content` kwarg on `ainvoke()` — overrides the instance
default for one call.
- When set, threads into `config['cached_content']` before all three
`generate_content` calls (string output, native JSON, fallback JSON).

Per-call kwarg takes precedence over the instance default, so you can
pin a cache for the whole session and still override per-call when
needed.

## What's NOT in this PR

- Cache creation (`client.caches.create(...)`) is left to the caller.
That gives users full control over TTL, contents, and lifecycle without
coupling the LLM wrapper to agent-state decisions.
- Agent-side automatic cache lifecycle (create on first step, reuse on
subsequent steps, refresh near TTL) is an obvious follow-up but a
separate design discussion — it touches `agent/service.py` and depends
on what the agent considers its "stable prefix."

## Usage

```python
from google.genai import types
from google import genai

client = genai.Client(api_key=...)
cache = await client.aio.caches.create(
    model='gemini-2.5-flash',
    config=types.CreateCachedContentConfig(
        contents=[...prefix turns...],
        system_instruction='...',
        ttl='3600s',
    ),
)

llm = ChatGoogle(model='gemini-2.5-flash', cached_content=cache.name)
# Every ainvoke() now references that cache.

# Per-call override:
await llm.ainvoke(messages, cached_content='cachedContents/other')
```

## Test plan

- [x] New unit test `test_cached_content_threaded_into_config` —
verifies the kwarg flows into `generate_content`'s `config` dict, the
per-call kwarg overrides the instance default, and when unset the key is
absent (`pytest tests/ci/models/test_llm_google.py`).
- [x] Existing google tests still pass.
- [ ] Real-API smoke test against a Gemini model with an actual
`cachedContents/...` resource (requires API key + paid quota — not in
CI).

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Adds explicit Gemini CachedContent support to `ChatGoogle` by forwarding
a `cached_content` name into all `generate_content` calls. Addresses
#4887 (item 4) to enable deterministic cache reuse with discounted
billing.

- **New Features**
- Add `cached_content` on `ChatGoogle` with per-call override via
`ainvoke(..., cached_content=...)`.
  - Thread to `config['cached_content']` for all paths; omit when unset.
- Cache creation is caller-managed; usage already counts
`prompt_cached_tokens`.

- **Migration**
- No breaking changes; behavior is unchanged when `cached_content` is
unset.
- To adopt: create a Gemini cache and pass its name via
`ChatGoogle(cached_content=...)` or `ainvoke(..., cached_content=...)`.

<sup>Written for commit ac5ff6d.
Summary will update on new commits. <a
href="https://cubic.dev/pr/browser-use/browser-use/pull/4889?utm_source=github">Review
in cubic</a></sup>

<!-- End of auto-generated description by cubic. -->
r266-tech pushed a commit to r266-tech/browser-use that referenced this pull request May 26, 2026
…er-use#4889)

## Context

Closes part of browser-use#4887 (item browser-use#4 — explicit CachedContent support).

Gemini's implicit context cache is great for the steady-state of an
agent loop but has a ~5-minute TTL and is per-call best-effort. For long
sessions (or sessions that go quiet for >5 minutes and resume), explicit
`CachedContent` is the deterministic alternative: you create a named
cache once with the prefix, then reference it on subsequent calls and
Google bills the cached portion at the discounted rate, period.

The wrapper in `browser_use/llm/google/chat.py` already parses
`cached_content_token_count` out of `response.usage_metadata` into
`ChatInvokeUsage.prompt_cached_tokens`, so the savings are visible — it
just had no way to *send* a cache reference.

## Change

- New `cached_content: str | None = None` field on `ChatGoogle`.
- New `cached_content` kwarg on `ainvoke()` — overrides the instance
default for one call.
- When set, threads into `config['cached_content']` before all three
`generate_content` calls (string output, native JSON, fallback JSON).

Per-call kwarg takes precedence over the instance default, so you can
pin a cache for the whole session and still override per-call when
needed.

## What's NOT in this PR

- Cache creation (`client.caches.create(...)`) is left to the caller.
That gives users full control over TTL, contents, and lifecycle without
coupling the LLM wrapper to agent-state decisions.
- Agent-side automatic cache lifecycle (create on first step, reuse on
subsequent steps, refresh near TTL) is an obvious follow-up but a
separate design discussion — it touches `agent/service.py` and depends
on what the agent considers its "stable prefix."

## Usage

```python
from google.genai import types
from google import genai

client = genai.Client(api_key=...)
cache = await client.aio.caches.create(
    model='gemini-2.5-flash',
    config=types.CreateCachedContentConfig(
        contents=[...prefix turns...],
        system_instruction='...',
        ttl='3600s',
    ),
)

llm = ChatGoogle(model='gemini-2.5-flash', cached_content=cache.name)
# Every ainvoke() now references that cache.

# Per-call override:
await llm.ainvoke(messages, cached_content='cachedContents/other')
```

## Test plan

- [x] New unit test `test_cached_content_threaded_into_config` —
verifies the kwarg flows into `generate_content`'s `config` dict, the
per-call kwarg overrides the instance default, and when unset the key is
absent (`pytest tests/ci/models/test_llm_google.py`).
- [x] Existing google tests still pass.
- [ ] Real-API smoke test against a Gemini model with an actual
`cachedContents/...` resource (requires API key + paid quota — not in
CI).

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Adds explicit Gemini CachedContent support to `ChatGoogle` by forwarding
a `cached_content` name into all `generate_content` calls. Addresses
browser-use#4887 (item 4) to enable deterministic cache reuse with discounted
billing.

- **New Features**
- Add `cached_content` on `ChatGoogle` with per-call override via
`ainvoke(..., cached_content=...)`.
  - Thread to `config['cached_content']` for all paths; omit when unset.
- Cache creation is caller-managed; usage already counts
`prompt_cached_tokens`.

- **Migration**
- No breaking changes; behavior is unchanged when `cached_content` is
unset.
- To adopt: create a Gemini cache and pass its name via
`ChatGoogle(cached_content=...)` or `ainvoke(..., cached_content=...)`.

<sup>Written for commit ac5ff6d.
Summary will update on new commits. <a
href="https://cubic.dev/pr/browser-use/browser-use/pull/4889?utm_source=github">Review
in cubic</a></sup>

<!-- End of auto-generated description by cubic. -->
MagMueller added a commit to MagMueller/browser-use that referenced this pull request May 30, 2026
real_v8 task kn785tsf6gykwc40a6yxgxe6hs87pr12 (Sziget ticket scrape)
ran 16 browser steps + saved sziget_tickets.json + answered "Scrape
complete. The CSV/JSON is in the run's outputs directory." Judge has
no filesystem access → marked failed. selfReportSuccess: false.

Pattern: agents finish the work but bury the answer in saved files.
Directive browser-use#4 now forbids that — must inline the actual extracted data.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
MrNagabhushana-0-dev referenced this pull request in MrNagabhushana-0-dev/browser-use- Sep 20, 2026
A screenshot is the wrong unit for anything that moves. It costs ~1,400 tokens
at 1280x800, it describes a moment that has already passed, and it says nothing
about motion — two of them have to be diffed by the reader before they mean
anything. That is why watching a video or playing a game by screenshotting is
both expensive and late, and why it plays like a slideshow.

What a person gets from their visual system is not a sequence of pictures. It
is a small, continuously updated model of the few things that matter: what is
here, where it is, which way it is going, what is about to hit what. That is a
few dozen symbols, and it is already differentiated.

So: vision/perceive.py reduces a frame pair to the blobs that changed, and
vision/stream.py keeps their identity across frames — predict each object
forward by its velocity, match this frame's blobs to those predictions inside a
gate, age out what stops appearing. Identity is the part that makes velocity
mean anything. Output is one line per frame:

  t=2.4 pan=left | #1* (0.21,0.62) v(+0.00,+0.05) | #4 (0.78,0.61) v(-0.09,+0.00) ttc=0.9

with the longest-lived object marked as the likely avatar (games keep the thing
you control on screen while obstacles come and go) and time-to-contact for
anything closing on it — the quantity a player is actually computing.

Measured on real captures from Big Buck Bunny and a live game: 38-41x fewer
tokens than the equivalent images, 15-35ms a frame, no model to download. The
watch_page action now sends this stream and two pictures rather than eight,
because the stream says what moved and pictures are for the one thing text
cannot do, which is recognise what something is.

Also in here, found by running it rather than by reading it:

- LiveView captured nothing during a recording. It filtered frames by its own
  CDP session, but when the recorder owns the stream the session that matters
  is the recorder's. A watch during a recording therefore saw zero frames and
  dropped the recorder's acknowledgements with them.
- HumanInput had no way to hold anything. A tap and a hold are different
  inputs, and games are where that shows: accelerating, charging a jump and
  steering are all "the key is still down". hold() and press_and_hold() send
  auto-repeat the way a real keyboard does.
- The browser announced HeadlessChrome in its User-Agent, and reported
  outerWidth 780 against innerWidth 1280 — a window smaller than its own
  viewport, which no real browser can be. Both now match a normal Chrome.
- cobrowse.attach() raised TypeError on any profile-level argument, at the
  moment of handover; it now routes them and rejects launch-time options with
  a clear message. A stale profile lock reported itself as "exited with code
  21" and now says which process holds it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013mvkJSRqASuCudGU4bwZQY
MrNagabhushana-0-dev referenced this pull request in MrNagabhushana-0-dev/browser-use- Sep 22, 2026
The perception stream said where things were and which way they moved; it did
not say what they were. "Something is moving in the lower left" is a weaker
sentence than "a button is in the lower left", and a screenshot carries the
what for free — at ~1,400 tokens. This carries it for a few.

browser_use/vision/label.py reads three cheap features over a region — edge
density (text and dense UI transition often; a photo or a flat control do not),
colour variance (media varies wildly, chrome is near-flat), and size/shape —
and maps them to a coarse label: text, button, media, panel, region. Decoded
once per frame, queried per blob, no model to download. The stream now renders
it inline:

  t=2.4 pan=left | #1* button (0.21,0.62) v(+0.00,+0.05) | #4 media (0.78,0.61) ttc=0.9

Two limits found by measurement rather than assumed, and designed around:

- icon and button are not separable at this grid resolution — a tiny block
  cannot have an interior cell that avoids its own border — so they share one
  honest label instead of a distinction the pixels cannot support.
- a *moving* thing's motion blob straddles its own border, so it reads
  region/media, not the flat 'button' its interior would. Labels settle to
  button/panel/text for stable or large regions; that is the correct behaviour,
  and the stream test asserts the channel is present and drawn from the
  vocabulary rather than pretending motion labels furniture.

A finer taxonomy is a segmentation model's job — a strictly larger dependency;
this is the part that pays for itself with no weights at all. Every label is a
guess from pixels and is named as one.

Tests: test_vision_label.py (8), built from synthetic frames because CI cannot
depend on a live page looking the same next year. The thresholds were
calibrated against real captured frames first, then the synthetic frames
constructed to reproduce those feature magnitudes through the JPEG+downscale
path.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013mvkJSRqASuCudGU4bwZQY
eddyflores100-lang pushed a commit to eddyflores100-lang/browser-use that referenced this pull request Nov 6, 2026
…-closed + 6 P2 fixes)

Addresses all 7 issues raised by cubic-dev-ai[bot] in its review on
PR browser-use#6226 (review run 978321d8-5481-5e5a-baa4-f7acfa7415cb).

P1 — filter_trusted trusts on lookup exception (trust.py:147)
  filter_trusted used to append a URL to trusted[] when its lookup
  raised and allow_unknown=True. That is wrong: allow_unknown applies
  ONLY to explicit TrustVerdict(score=None) results. A lookup that
  raised did not produce a verdict, so the server must not be trusted.
  Lookup exceptions are now ALWAYS fail-closed, regardless of
  allow_unknown. The class docstring spells this out.
  New test: test_lookup_exception_is_fail_closed_even_with_allow_unknown.

P2 browser-use#1 — inclusive threshold not tested (test_trust.py:11)
  Added test_threshold_is_inclusive_at_boundary that asserts a verdict
  with score=0.7 against min_score=0.7 is trusted. Locks down the >=
  comparison so an accidental switch to > would fail CI.

P2 browser-use#2 — Ruff double-quote style (test_trust.py:14)
  All new string literals switched to single quotes to match the
  repo's Ruff config. Ran 'ruff format' on both files; clean.

P2 browser-use#3 — credentials in lookup URL (trust.py:64)
  Added _strip_credentials_from_url that drops userinfo (user:pass@)
  and secret-bearing query parameters (api_key, token, access_token,
  secret, password, auth) before the URL is sent to the third-party
  trust API. Non-secret query params (page, etc.) are preserved.
  New test: test_strip_credentials_from_url covers userinfo, secret
  query, non-secret query, and port preservation.

P2 browser-use#4 — out-of-range scores (trust.py:75)
  Score validation now rejects NaN, inf, and any value outside
  [0.0, 100.0] before normalizing. A score=200 would previously
  normalize to 2.0 and pass any threshold <= 1.0. String scores
  ('0.85') are coerced to float; non-numeric strings are rejected.
  New test: test_default_lookup_rejects_out_of_range_score.

P2 browser-use#5 — malformed 200 escapes (trust.py:82)
  The except clause now catches ValueError, TypeError, AttributeError
  in addition to httpx.RequestError and asyncio.TimeoutError. A 200
  response with malformed JSON or a non-object body returns a fail-
  closed verdict with a reason, instead of raising out of check().
  New test: test_default_lookup_handles_malformed_200.

P2 browser-use#6 — TrustChecker not wired into agent (trust.py:95)
  Not fixed in this PR by design: keeping the change small and
  reviewable. The PR title and docstring already describe the module
  as a standalone helper. A follow-up PR will wire it into the MCP
  client connection path. Reply in the review thread.

Tests: 11 pass, 0 fail. Ruff check + format clean.
DCO: Signed-off-by: Edison Flores <[email protected]>
eddyflores100-lang added a commit to eddyflores100-lang/browser-use that referenced this pull request Nov 6, 2026
…-closed + 6 P2 fixes)

Addresses all 7 issues raised by cubic-dev-ai[bot] in its review on
PR browser-use#6226 (review run 978321d8-5481-5e5a-baa4-f7acfa7415cb).

P1 — filter_trusted trusts on lookup exception (trust.py:147)
  filter_trusted used to append a URL to trusted[] when its lookup
  raised and allow_unknown=True. That is wrong: allow_unknown applies
  ONLY to explicit TrustVerdict(score=None) results. A lookup that
  raised did not produce a verdict, so the server must not be trusted.
  Lookup exceptions are now ALWAYS fail-closed, regardless of
  allow_unknown. The class docstring spells this out.
  New test: test_lookup_exception_is_fail_closed_even_with_allow_unknown.

P2 browser-use#1 — inclusive threshold not tested (test_trust.py:11)
  Added test_threshold_is_inclusive_at_boundary that asserts a verdict
  with score=0.7 against min_score=0.7 is trusted. Locks down the >=
  comparison so an accidental switch to > would fail CI.

P2 browser-use#2 — Ruff double-quote style (test_trust.py:14)
  All new string literals switched to single quotes to match the
  repo's Ruff config. Ran 'ruff format' on both files; clean.

P2 browser-use#3 — credentials in lookup URL (trust.py:64)
  Added _strip_credentials_from_url that drops userinfo (user:pass@)
  and secret-bearing query parameters (api_key, token, access_token,
  secret, password, auth) before the URL is sent to the third-party
  trust API. Non-secret query params (page, etc.) are preserved.
  New test: test_strip_credentials_from_url covers userinfo, secret
  query, non-secret query, and port preservation.

P2 browser-use#4 — out-of-range scores (trust.py:75)
  Score validation now rejects NaN, inf, and any value outside
  [0.0, 100.0] before normalizing. A score=200 would previously
  normalize to 2.0 and pass any threshold <= 1.0. String scores
  ('0.85') are coerced to float; non-numeric strings are rejected.
  New test: test_default_lookup_rejects_out_of_range_score.

P2 browser-use#5 — malformed 200 escapes (trust.py:82)
  The except clause now catches ValueError, TypeError, AttributeError
  in addition to httpx.RequestError and asyncio.TimeoutError. A 200
  response with malformed JSON or a non-object body returns a fail-
  closed verdict with a reason, instead of raising out of check().
  New test: test_default_lookup_handles_malformed_200.

P2 browser-use#6 — TrustChecker not wired into agent (trust.py:95)
  Not fixed in this PR by design: keeping the change small and
  reviewable. The PR title and docstring already describe the module
  as a standalone helper. A follow-up PR will wire it into the MCP
  client connection path. Reply in the review thread.

Tests: 11 pass, 0 fail. Ruff check + format clean.
DCO: Signed-off-by: Edison Flores <[email protected]>
eddyflores100-lang added a commit to eddyflores100-lang/browser-use that referenced this pull request Nov 6, 2026
…-closed + 6 P2 fixes)

Addresses all 7 issues raised by cubic-dev-ai[bot] in its review on
PR browser-use#6226 (review run 978321d8-5481-5e5a-baa4-f7acfa7415cb).

P1 — filter_trusted trusts on lookup exception (trust.py:147)
  filter_trusted used to append a URL to trusted[] when its lookup
  raised and allow_unknown=True. That is wrong: allow_unknown applies
  ONLY to explicit TrustVerdict(score=None) results. A lookup that
  raised did not produce a verdict, so the server must not be trusted.
  Lookup exceptions are now ALWAYS fail-closed, regardless of
  allow_unknown. The class docstring spells this out.
  New test: test_lookup_exception_is_fail_closed_even_with_allow_unknown.

P2 browser-use#1 — inclusive threshold not tested (test_trust.py:11)
  Added test_threshold_is_inclusive_at_boundary that asserts a verdict
  with score=0.7 against min_score=0.7 is trusted. Locks down the >=
  comparison so an accidental switch to > would fail CI.

P2 browser-use#2 — Ruff double-quote style (test_trust.py:14)
  All new string literals switched to single quotes to match the
  repo's Ruff config. Ran 'ruff format' on both files; clean.

P2 browser-use#3 — credentials in lookup URL (trust.py:64)
  Added _strip_credentials_from_url that drops userinfo (user:pass@)
  and secret-bearing query parameters (api_key, token, access_token,
  secret, password, auth) before the URL is sent to the third-party
  trust API. Non-secret query params (page, etc.) are preserved.
  New test: test_strip_credentials_from_url covers userinfo, secret
  query, non-secret query, and port preservation.

P2 browser-use#4 — out-of-range scores (trust.py:75)
  Score validation now rejects NaN, inf, and any value outside
  [0.0, 100.0] before normalizing. A score=200 would previously
  normalize to 2.0 and pass any threshold <= 1.0. String scores
  ('0.85') are coerced to float; non-numeric strings are rejected.
  New test: test_default_lookup_rejects_out_of_range_score.

P2 browser-use#5 — malformed 200 escapes (trust.py:82)
  The except clause now catches ValueError, TypeError, AttributeError
  in addition to httpx.RequestError and asyncio.TimeoutError. A 200
  response with malformed JSON or a non-object body returns a fail-
  closed verdict with a reason, instead of raising out of check().
  New test: test_default_lookup_handles_malformed_200.

P2 browser-use#6 — TrustChecker not wired into agent (trust.py:95)
  Not fixed in this PR by design: keeping the change small and
  reviewable. The PR title and docstring already describe the module
  as a standalone helper. A follow-up PR will wire it into the MCP
  client connection path. Reply in the review thread.

Tests: 11 pass, 0 fail. Ruff check + format clean.
DCO: Signed-off-by: Edison Flores <[email protected]>
eddyflores100-lang added a commit to eddyflores100-lang/browser-use that referenced this pull request Nov 6, 2026
…n, CancelledError (cubic-dev-ai review round 2)

Addresses the 5 new issues raised by cubic-dev-ai[bot] in its second
and third reviews on PR browser-use#6226 (2026-11-06 01:54 and 02:05), all against
the recent commits that fixed the original 7 issues.

P1 browser-use#4 (trust.py:259, review 2026-11-06 01:54) — filter_trusted logs raw URLs
  filter_trusted's warning and info log lines logged the raw server_url,
  so credentials embedded in a URL (e.g. https://user:pass@host?api_key=...)
  reached application logs even though the API request had them stripped.
  Added _redact_url_for_logging helper that strips userinfo and secret
  query params before logging; both warning and info paths now use it.
  Two new tests: test_filter_trusted_logs_redacted_url_on_exception and
  test_filter_trusted_logs_redacted_url_on_skip — both assert the raw
  URL never appears in caplog.text.

P2 browser-use#1 (trust.py:69) — IPv6 brackets dropped by sanitizer
  _strip_credentials_from_url used parts.hostname, which strips the
  brackets from an IPv6 address; urlunsplit then produced a malformed
  URL (the colon in the IPv6 address is ambiguous with the port
  separator). Re-add brackets around colon-containing hostnames before
  building the netloc.
  New test: test_strip_credentials_preserves_ipv6_brackets covers
  [::1]:8443 and [2001:db8::1] cases.

P2 browser-use#2 (trust.py:70) — invalid port escapes sanitizer
  parts.port raises ValueError on a malformed port substring like
  'abc' (e.g. https://host:abc/). That ValueError escaped the sanitizer
  and the lookup raised before the fail-closed handler could catch it.
  Wrapped parts.port access in try/except (ValueError, TypeError) and
  treat invalid port as no port.
  New test: test_strip_credentials_handles_invalid_port asserts the
  sanitizer returns a URL without :abc and does not raise.

P2 browser-use#3 (trust.py:139) — score validator accepts JSON booleans
  bool is a subclass of int in Python, so isinstance(True, int) is
  True and float(True) returns 1.0. A JSON `true` in the trust_score
  field would normalize to 1.0 and pass any threshold <= 1.0. Added
  an explicit isinstance(score, bool) check before numeric coercion
  that rejects booleans with a fail-closed verdict.
  New test: test_default_lookup_rejects_boolean_score asserts the
  verdict has score=None and the reason mentions 'boolean'.

P2 browser-use#5 (trust.py:256, review 2026-11-06 02:05) — BaseException reaches cast
  asyncio.gather with return_exceptions=True returns List[TrustVerdict |
  BaseException]. The isinstance(result, Exception) guard only catches
  Exception subclasses, not BaseException. A CancelledError (which is a
  BaseException since Python 3.8) reached the cast and crashed with
  AttributeError on verdict.is_trusted instead of preserving the
  cancellation. Now we re-raise asyncio.CancelledError and any other
  BaseException that isn't an Exception subclass (KeyboardInterrupt,
  SystemExit) before the cast.
  New test: test_filter_trusted_propagates_cancelled_error asserts that
  a CancelledError raised by the lookup propagates instead of being
  swallowed as fail-closed.

Tests: 17 pass, 0 fail (was 11, +6 new). pyright clean. ruff format clean.
DCO: Signed-off-by: Edison Flores <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant