For now I am using manual asyncio locks on the tools. Disabling parallel tool calling didn’t fix the issue and middleware probably could fix the issue but looks like it would take significantly more time. For now this is working
class PlaywrightAgent:
page: Page
base_url: str
_lock: asyncio.Lock
....
async def _visit_url(self, url: str) -> str:
async with self._lock:
await self.page.goto(url=url)
return self.page.url