Bug: Problematic type comparison when using page custom variable
Browser Use Version
0.5.4
Bug Description, Steps to Reproduce, Screenshots
When using page: Page with playwright.async_api.Page as a special argument in a custom function, the registration of the custom action fails due to a parameter conflict with the special argument.
I believe this is due to a bug in the type comparison - the expected type of page is a union between playwright and patchright's Page classes and this union isn't correctly compared to a single type.
Failing Python Code
from playwright.async_api import Page
controller = Controller()
@controller.action("Get the HTML content of the current page")
async def get_current_page_html(
page: Page
) -> str:
return await page.content()
LLM Model
gpt-4o
Operating System & Browser Versions
MacOS Sequoia 15.5 + chromium
Full DEBUG Log Output
you can probably not put the type and it should work, right? Maybe I am wrong
you can probably not put the type and it should work, right? Maybe I am wrong
You can avoid putting the type, or explicity specify the union between both libraries (which is our current solution), but I wouldn't want to avoid having type checking for the function, and the union usage is kind of ugly. In previous versions simply using playwright's Page worked, and in upgrading to 0.5.4 our code broke due to this change