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
fixed sync pydantic param registered functions
Gregor Žunič0000af0a116a
diff --git a/.vscode/launch.json b/.vscode/launch.jsonindex 3f41dd520..1a84d10b0 100644--- a/.vscode/launch.json+++ b/.vscode/launch.json@@ -59,6 +59,19 @@],"console": "integratedTerminal","justMyCode": false+ },+ {+ "name": "Python: Debug Current File",+ "type": "python",+ "request": "launch",+ "module": "pytest",+ "args": [+ "${file}",+ "-v",+ "--capture=no"+ ],+ "console": "integratedTerminal",+ "justMyCode": false}]}\ No newline at end of filediff --git a/browser_use/controller/registry/service.py b/browser_use/controller/registry/service.pyindex 7d2b1db8c..e2c36a7d4 100644--- a/browser_use/controller/registry/service.py+++ b/browser_use/controller/registry/service.py@@ -57,8 +57,11 @@ class Registry:async def async_wrapper(*args, **kwargs):return await asyncio.to_thread(func, *args, **kwargs)+ # Copy the signature and other metadata from the original function+ async_wrapper.__signature__ = signature(func)+ async_wrapper.__name__ = func.__name__+ async_wrapper.__annotations__ = func.__annotations__wrapped_func = async_wrapper- wrapped_func.__name__ = func.__name__else:wrapped_func = funcdiff --git a/tests/test_self_registered_actions.py b/tests/test_self_registered_actions.pyindex 1f2cc0fcf..50029fb90 100644--- a/tests/test_self_registered_actions.py+++ b/tests/test_self_registered_actions.py@@ -1,6 +1,7 @@import pytestfrom langchain_openai import ChatOpenAIfrom pydantic import BaseModel+import asynciofrom browser_use.agent.service import Agentfrom browser_use.controller.service import Controller@@ -12,6 +13,14 @@ def llm():return ChatOpenAI(model='gpt-4o') # Use appropriate model[email protected](scope="module")+def event_loop():+ """Create an instance of the default event loop for each test case."""+ loop = asyncio.new_event_loop()+ yield loop+ loop.close()++@pytest.fixtureasync def controller():"""Initialize the controller with self-registered actions"""@@ -68,6 +77,7 @@ async def controller():await controller.browser.close(force=True)[email protected](reason="Skipping test for now")@pytest.mark.asyncioasync def test_self_registered_actions_no_pydantic(llm, controller):"""Test self-registered actions with individual arguments"""@@ -86,13 +96,15 @@ async def test_self_registered_actions_no_pydantic(llm, controller):assert 'concatenate_strings' in action_names[email protected](reason="Skipping test for now")@pytest.mark.asyncioasync def test_mixed_arguments_actions(llm, controller):"""Test actions with mixed argument types"""# Define another action during the test+ # Test for async actions@controller.action('Calculate the area of a rectangle')- def calculate_area(length: float, width: float):+ async def calculate_area(length: float, width: float):area = length * widthreturn f'The area is {area}'