From 4268f352c81f8b9a59d3dc31abff755c14bfe5e4 Mon Sep 17 00:00:00 2001 From: jiayuww Date: Wed, 1 Jul 2026 21:34:06 +0000 Subject: [PATCH] Fix TypeError: 3 task checkers reject the current_url kwarg the env passes add_tasks_to_browsergym.reward() calls check_if_task_is_complete(initial_state, current_state, current_url=...), and the base Task + most subclasses accept current_url, but NavigateToAppTask, DeleteToDoTask, and RemoveLandmarkTask were left at the 2-arg signature. Every task instance of those classes crashes with 'TypeError: .check_if_task_is_complete() got an unexpected keyword argument current_url' the moment the env computes reward, so they can never be scored (reward path aborts). Repro (dummy agent, no model needed): uv run launch_agent.py agent=dummy task_name=navigate_from_todo_to_calendar # also: task_name=delete_call_aunt_lisa, remove_times_square_from_favorites Fix: accept current_url in all three. NavigateToAppTask now prefers the env-provided current_url (falling back to current_state['_url'] for older callers); the click-only Delete/Remove checkers accept-and-ignore it (they compare app state). Reward semantics unchanged; after the fix the repro runs to completion and scores instead of crashing. --- src/open_apps/tasks/tasks.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/open_apps/tasks/tasks.py b/src/open_apps/tasks/tasks.py index 31823bc..257b9c3 100644 --- a/src/open_apps/tasks/tasks.py +++ b/src/open_apps/tasks/tasks.py @@ -411,7 +411,7 @@ def get_target_state(self, initial_state: dict) -> dict: return target_state def check_if_task_is_complete( - self, initial_state: dict, current_state: dict + self, initial_state: dict, current_state: dict, current_url: str | None = None ) -> bool: target_state = self.get_target_state(initial_state) app_state_comparison = AppStateComparison(target_state, current_state) @@ -435,7 +435,7 @@ def get_target_state(self, initial_state: dict) -> dict: return target_state def check_if_task_is_complete( - self, initial_state: dict, current_state: dict + self, initial_state: dict, current_state: dict, current_url: str | None = None ) -> bool: target_state = self.get_target_state(initial_state) app_state_comparison = AppStateComparison(target_state, current_state) @@ -467,9 +467,14 @@ class NavigateToAppTask(Task): target_app: str def check_if_task_is_complete( - self, initial_state: dict, current_state: dict + self, initial_state: dict, current_state: dict, current_url: str | None = None ) -> bool: - url = current_state.get("_url", "") if isinstance(current_state, dict) else "" + # The env passes the live page URL via ``current_url`` (see + # add_tasks_to_browsergym.reward). Older callers injected it as + # ``current_state['_url']`` -- fall back to that for compatibility. + url = current_url or ( + current_state.get("_url", "") if isinstance(current_state, dict) else "" + ) if not url: return False try: