Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/narada-pyodide/src/narada/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ async def dispatch_request(
"prompt": agent_prefix + prompt,
"browserWindowId": self.browser_window_id,
"timeZone": time_zone,
"timeout": timeout,
}
parent_run_ids = self._current_parent_run_ids()
if parent_run_ids:
Expand Down
4 changes: 3 additions & 1 deletion packages/narada-pyodide/tests/test_cloud_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ async def test_local_browser_window_dispatch_request_uses_latest_parent_run_ids(
window = window_module.LocalBrowserWindow()

window_module._narada_parent_run_ids = _FakeJsProxy(["run-a"])
first_response = await window.dispatch_request(prompt="first prompt")
first_response = await window.dispatch_request(prompt="first prompt", timeout=17)

window_module._narada_parent_run_ids = _FakeJsProxy(["run-b", "run-c"])
second_response = await window.dispatch_request(prompt="second prompt")
Expand All @@ -852,6 +852,8 @@ async def test_local_browser_window_dispatch_request_uses_latest_parent_run_ids(

first_post = json.loads(pyfetch.await_args_list[0].kwargs["body"])
second_post = json.loads(pyfetch.await_args_list[2].kwargs["body"])
assert first_post["timeout"] == 17
assert second_post["timeout"] == 1000
assert first_post["parentRunIds"] == ["run-a"]
assert second_post["parentRunIds"] == ["run-b", "run-c"]

Expand Down
1 change: 1 addition & 0 deletions packages/narada/src/narada/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ async def dispatch_request(
"prompt": agent_prefix + prompt,
"browserWindowId": self.browser_window_id,
"timeZone": time_zone,
"timeout": timeout,
}
cloud_browser_session_id = self.cloud_browser_session_id
if cloud_browser_session_id is not None:
Expand Down
22 changes: 22 additions & 0 deletions packages/narada/tests/test_window_human_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,28 @@ def post(self, _url: str, **kwargs: Any) -> _FakeResponse:
self.post_bodies.append(kwargs["json"])
return _FakeResponse(next(self._responses))

def get(self, _url: str, **_kwargs: Any) -> _FakeResponse:
return _FakeResponse(next(self._responses))


@pytest.mark.asyncio
async def test_dispatch_request_forwards_timeout(
monkeypatch: pytest.MonkeyPatch,
) -> None:
fake_session = _FakeSession(
[
{"requestId": "request-123"},
{"status": "success", "response": None},
]
)
monkeypatch.setattr("narada.window.aiohttp.ClientSession", lambda: fake_session)
window = RemoteBrowserWindow(browser_window_id="bw-1", api_key="test-key")

response = await window.dispatch_request(prompt="hello", timeout=17)

assert response["status"] == "success"
assert fake_session.post_bodies[0]["timeout"] == 17


@pytest.mark.asyncio
async def test_prompt_for_user_input_uses_hitl_default_timeout(
Expand Down
Loading