Skip to content

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

fix error in not initializing controller correctly

mertunsalld8a08f088e06
diff --git a/browser_use/integrations/gmail/actions.py b/browser_use/integrations/gmail/actions.py
index 5efdcb3a4..2366372bf 100644
--- a/browser_use/integrations/gmail/actions.py
+++ b/browser_use/integrations/gmail/actions.py
@@ -28,7 +28,7 @@ class GetRecentEmailsParams(BaseModel):
def register_gmail_actions(
controller: Controller, gmail_service: GmailService | None = None, access_token: str | None = None
-) -> None:
+) -> Controller:
"""
Register Gmail actions with the provided controller
Args:
@@ -46,7 +46,7 @@ def register_gmail_actions(
else:
_gmail_service = GmailService()
- @controller.action(
+ @controller.registry.action(
description='Get recent emails from the mailbox with a query to retrieve verification codes, OTP, 2FA tokens, or any recent email content.',
param_model=GetRecentEmailsParams,
)
@@ -113,3 +113,5 @@ def register_gmail_actions(
error=f'Error getting recent emails: {str(e)}',
long_term_memory='Failed to get recent emails due to error',
)
+
+ return controller
diff --git a/eval/service.py b/eval/service.py
index 974ba2ad9..56dcf534e 100644
--- a/eval/service.py
+++ b/eval/service.py
@@ -923,7 +923,7 @@ def create_controller(
from browser_use.integrations.gmail import register_gmail_actions
# Register Gmail actions using the access token
- register_gmail_actions(controller, access_token=access_token)
+ controller = register_gmail_actions(controller, access_token=access_token)
logger.info(f'Gmail 2FA integration registered successfully for user {user_id}')
else:
logger.info(f'No Gmail 2FA token found for user {user_id}, running without Gmail integration')