Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

fixed UnionType type error

Gregor Žunič1e93ca5a9f2c
diff --git a/browser_use/controller/registry/service.py b/browser_use/controller/registry/service.py
index 6680312fd..9737661b4 100644
--- a/browser_use/controller/registry/service.py
+++ b/browser_use/controller/registry/service.py
@@ -5,6 +5,7 @@ import logging
import re
from collections.abc import Callable
from inspect import Parameter, iscoroutinefunction, signature
+from types import UnionType
from typing import Any, Generic, Optional, TypeVar, Union, get_args, get_origin
from pydantic import BaseModel, Field, RootModel, create_model
@@ -39,7 +40,7 @@ class Registry(Generic[Context]):
self.telemetry = ProductTelemetry()
self.exclude_actions = exclude_actions if exclude_actions is not None else []
- def _get_special_param_types(self) -> dict[str, type | None]:
+ def _get_special_param_types(self) -> dict[str, type | UnionType | None]:
"""Get the expected types for special parameters from SpecialActionParameters"""
# Manually define the expected types to avoid issues with Optional handling.
# we should try to reduce this list to 0 if possible, give as few standardized objects to all the actions