Skip to content

[BUG]: browser-use does not work with aiq serve #26

@alexliap

Description

@alexliap

Version

1.1.0

Which installation method(s) does this occur on?

Pip

Describe the bug.

I have added an extra graph before the 2 existing ones, which makes use of the browser-use library. The graph has only one node and uses the simple function below:

async def auto_browser_use(state: AIRAState, config: RunnableConfig):
    objective = config["configurable"].get("objective")
    browsing_llm = config["configurable"].get("browsing_llm")
    page_extraction_llm = config["configurable"].get("page_extraction_llm")

    agent = Agent(
        task=f"Objective:\n{objective}",
        llm=ChatOpenAI(
            model=browsing_llm,
            temperature=1,
        ),
        page_extraction_llm=ChatOpenAI(
            model=page_extraction_llm, temperature=0,
        ),
        browser_profile=BrowserProfile(headless=False),
        override_system_message=auto_browser_intruction,
        max_actions_per_step=8,
    )
    history = await agent.run(max_steps=25)
    contents = history.extracted_content()
    final_result = history.final_result()

    browser_use_results = """
    Browser Extracted content:
    {content}

    Final Result:
    {final_results}
    """

    return {
        "browser_use_results": browser_use_results.format(
            content="\n".join(contents), final_results=final_result
        )
    }

When the workflow is used with aiq run command it is running fine, it begins browsing and everything.
But when i am trying to host it with aiq serve the browsing capability stops and i get this error:

asyncio - ERROR - Task exception was never retrieved
future: <Task finished name='Task-92' coro=<Connection.run() done, defined at /Users/alexandrosliapatis/Desktop/Projects/aiq-research-assistant/.venv/lib/python3.12/site-packages/playwright/_impl/_connection.py:303> exception=NotImplementedError()>
Traceback (most recent call last):
  File "/Users/alexandrosliapatis/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/asyncio/tasks.py", line 314, in __step_run_and_handle_result
    result = coro.send(None)
             ^^^^^^^^^^^^^^^
  File "/Users/alexandrosliapatis/Desktop/Projects/aiq-research-assistant/.venv/lib/python3.12/site-packages/playwright/_impl/_connection.py", line 310, in run
    await self._transport.connect()
  File "/Users/alexandrosliapatis/Desktop/Projects/aiq-research-assistant/.venv/lib/python3.12/site-packages/playwright/_impl/_transport.py", line 133, in connect
    raise exc
  File "/Users/alexandrosliapatis/Desktop/Projects/aiq-research-assistant/.venv/lib/python3.12/site-packages/playwright/_impl/_transport.py", line 120, in connect
    self._proc = await asyncio.create_subprocess_exec(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alexandrosliapatis/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/asyncio/subprocess.py", line 224, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alexandrosliapatis/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/asyncio/base_events.py", line 1756, in subprocess_exec
    transport = await self._make_subprocess_transport(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alexandrosliapatis/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/asyncio/unix_events.py", line 200, in _make_subprocess_transport
    watcher = events.get_child_watcher()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alexandrosliapatis/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/asyncio/events.py", line 828, in get_child_watcher
    return get_event_loop_policy().get_child_watcher()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/alexandrosliapatis/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/asyncio/events.py", line 645, in get_child_watcher
    raise NotImplementedError
NotImplementedError

Given I dont have access to the aiq serve script i cant debug or change anything in its configuration.
I have tried hosting a tool with browser-use, with version0.1.48, before with fastapi and it works.
I cant use this version though because of the aira's dependencies.

Minimum reproducible example

Relevant log output

Full env printout

Other/Misc.

pyproject.toml

[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools >= 64", "setuptools-scm>=8"]

[tool.setuptools_scm]
root = ".."


[project]
name = "aiq_aira"
dynamic = ["version"]
dependencies = [
  "agentiq>=1.1.0a1",
  "agentiq-langchain>=1.1.0a1",
  "aiohappyeyeballs==2.4.4",
  "aiohttp",
  "aiosignal==1.3.2",
  "annotated-types==0.7.0",
  "anyio>=4.8.0",
  "arize-phoenix~=6.1",
  "async-timeout==5.0.1",
  "attrs==25.1.0",
  "certifi==2025.1.31",
  "charset-normalizer==3.4.1",
  "distro==1.9.0",
  "exceptiongroup==1.2.2",
  "frozenlist==1.5.0",
  "h11>=0.16.0",
  "httpcore",
  "httpx",
  "litellm",
  "idna==3.10",
  "jiter==0.8.2",
  "jsonpatch==1.33",
  "jsonpointer==3.0.0",
  "langchain-core",
  "langchain-openai",
  "langchain-nvidia-ai-endpoints",
  "langgraph==0.2.69",
  "langgraph-checkpoint==2.0.10",
  "langgraph-sdk==0.1.51",
  "langsmith==0.3.4",
  "msgpack==1.1.0",
  "multidict==6.1.0",
  "openai>=1.61.0",
  "orjson==3.10.15",
  "packaging==24.2",
  "propcache==0.2.1",
  "pydantic",
  "pydantic_core",
  "PyYAML==6.0.2",
  "redis==5.2.1",
  "regex==2024.11.6",
  "requests==2.32.3",
  "requests-toolbelt==1.0.0",
  "sniffio==1.3.1",
  "tenacity==9.0.0",
  "tiktoken==0.8.0",
  "tqdm==4.67.1",
  "typing_extensions==4.12.2",
  "urllib3==2.3.0",
  "xmltodict==0.14.2",
  "yarl==1.18.3",
  "zstandard==0.23.0",
  "colorama",
  "openinference-instrumentation-langchain",
  "openinference-instrumentation-openai",
  "pydantic-ai-slim[openai]>=0.5.0",
  "browser-use>0.1.48,<0.6"
]
requires-python = ">=3.12"
description = "AIRA AI-Q"
keywords = ["ai", "rag", "agents"]
classifiers = ["Programming Language :: Python"]

[project.optional-dependencies]
dev = [
    "aiohttp>=3.11.14",
    "docker>=7.1.0",
    "pytest>=8.3.5",
    "pytest-aiohttp>=1.1.0",
    "pytest-asyncio>=0.25.3",
    "pytest-dotenv>=0.5.2",
    "pre-commit",
]

[tool.uv.sources]
aiq = { path = "../ai-query-engine", editable = true }

[tool.uv]
managed = true
prerelease = "if-necessary-or-explicit"

[project.entry-points.'aiq.plugins']
aiq_aira = "aiq_aira.register"


# ===== yapf Config =====
[tool.yapf]
based_on_style = "pep8"
column_limit = 100
split_all_top_level_comma_separated_values = true
join_multiple_lines = true
indent_dictionary_value = true

[tool.pytest.ini_options]
env_files = [".env", "test.env"]

Code of Conduct

  • I agree to follow THIS PROJECT's Code of Conduct
  • I have searched the open bugs and have found no duplicates for this bug report

Metadata

Metadata

Assignees

No one assigned

    Labels

    AIQ1.0Version 1.0bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions