Playwright custom tool - should I use sync or async version?

I’ve created and tested separately my custom playwright_tool - it works.
But when I tried to use it in my crewai flow for 1 of agents - I got 2 types of warnings in logs:

  • if I use sync version of playwright - it logs out:
    I encountered an error while trying to use the tool. This was the error: It looks like you are using Playwright Sync API inside the asyncio loop.
    Please use the Async API instead…
  • if I use async version - it logs out coroutine, as the output of my tool:

Agent: URL My Scraper

Using tool: Playwright Scrape Website Tool

Tool Input:

“{"url": "some_url"}”

Tool Output:

<coroutine object PlaywrightTool._run at 0x000001C43A805F20>

Sure, my _run method is async:
async def _run(self, url: str) → dict:
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True)
page = await browser.new_page()
await page.goto(url, wait_until=“networkidle”)
etc

But _run is not awaited when crew is running.
So how to handle this?