Skip to content

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

fix: could not parse response on go_back action

j0yk1ll7c93f6c0e822
diff --git a/browser_use/controller/service.py b/browser_use/controller/service.py
index 62a0adaec..04728470e 100644
--- a/browser_use/controller/service.py
+++ b/browser_use/controller/service.py
@@ -4,7 +4,6 @@ import logging
from typing import Optional, Type
from main_content_extractor import MainContentExtractor
-from playwright.async_api import Page
from pydantic import BaseModel
from browser_use.agent.views import ActionModel, ActionResult
@@ -16,6 +15,7 @@ from browser_use.controller.views import (
ExtractPageContentAction,
GoToUrlAction,
InputTextAction,
+ NoParamsAction,
OpenTabAction,
ScrollAction,
SearchGoogleAction,
@@ -75,8 +75,8 @@ class Controller:
logger.info(msg)
return ActionResult(extracted_content=msg, include_in_memory=True)
- @self.registry.action('Go back', requires_browser=True)
- async def go_back(browser: BrowserContext):
+ @self.registry.action('Go back', param_model=NoParamsAction, requires_browser=True)
+ async def go_back(_: NoParamsAction, browser: BrowserContext):
await browser.go_back()
msg = '🔙 Navigated back'
logger.info(msg)
diff --git a/browser_use/controller/views.py b/browser_use/controller/views.py
index 5871579b9..37e009508 100644
--- a/browser_use/controller/views.py
+++ b/browser_use/controller/views.py
@@ -1,6 +1,6 @@
-from typing import Literal, Optional
+from typing import Optional
-from pydantic import BaseModel
+from pydantic import BaseModel, model_validator
# Action Input Models
@@ -45,3 +45,20 @@ class ScrollAction(BaseModel):
class SendKeysAction(BaseModel):
keys: str
+
+
+class NoParamsAction(BaseModel):
+ """
+ Accepts absolutely anything in the incoming data
+ and discards it, so the final parsed model is empty.
+ """
+
+ @model_validator(mode='before')
+ def ignore_all_inputs(cls, values):
+ # No matter what the user sends, discard it and return empty.
+ return {}
+
+ class Config:
+ # If you want to silently allow unknown fields at top-level,
+ # set extra = 'allow' as well:
+ extra = 'allow'