Skip to content
Closed
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
10 changes: 5 additions & 5 deletions gui_agents/s1/aci/LinuxOSACI.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def linearize_and_annotate_tree(self, obs, show_all=False):
def find_element(self, element_id):
try:
selected_element = self.nodes[int(element_id)]
except:
except Exception:
print("The index of the selected element was out of range.")
selected_element = self.nodes[0]
self.index_out_of_range_flag = True
Expand Down Expand Up @@ -414,7 +414,7 @@ def type(
try:
# Use the provided element_id or default to None
node = self.find_element(element_id) if element_id is not None else None
except:
except Exception:
node = None

if node is not None:
Expand Down Expand Up @@ -516,7 +516,7 @@ def scroll(self, element_id: int, clicks: int):
"""
try:
node = self.find_element(element_id)
except:
except Exception:
node = self.find_element(0)
# print(node.attrib)
coordinates = eval(
Expand Down Expand Up @@ -669,7 +669,7 @@ def _create_atspi_node(
]:
try:
attribute_dict[f"{value_key}{attr_name}"] = str(attr_func())
except:
except Exception:
pass
Comment on lines 670 to 673
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Silent except Exception: pass discards diagnostic info — add a log statement.

Any failure in attr_func() (e.g., a COM error or unexpected pyatspi error beyond NotImplementedError) is silently swallowed. Ruff S110 correctly flags this. A debug-level log preserves observability without changing behavior.

🔧 Proposed fix
             try:
                 attribute_dict[f"{value_key}{attr_name}"] = str(attr_func())
-            except Exception:
-                pass
+            except Exception as e:
+                logger.debug("Could not read value attribute %s for node %s: %s", attr_name, node_name, e)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try:
attribute_dict[f"{value_key}{attr_name}"] = str(attr_func())
except:
except Exception:
pass
try:
attribute_dict[f"{value_key}{attr_name}"] = str(attr_func())
except Exception as e:
logger.debug("Could not read value attribute %s for node %s: %s", attr_name, node_name, e)
🧰 Tools
🪛 Ruff (0.15.2)

[error] 672-673: try-except-pass detected, consider logging the exception

(S110)


[warning] 672-672: Do not catch blind exception: Exception

(BLE001)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@gui_agents/s1/aci/LinuxOSACI.py` around lines 670 - 673, The try/except
around calling attr_func() that sets attribute_dict[f"{value_key}{attr_name}"]
currently swallows all exceptions; change the except to log the exception at
debug level instead of passing so failures are observable. Specifically, inside
the except Exception block in LinuxOSACI.py where attribute_dict, value_key,
attr_name, and attr_func are used, call the module’s logger (or create one if
missing) to emit a debug log with a clear message including the attribute key
and the caught exception information (e.g., exception text/traceback) and then
continue preserving the current behavior (do not re-raise).

except NotImplementedError:
pass
Expand Down Expand Up @@ -748,7 +748,7 @@ def _create_atspi_node(
logger.warning("Max width reached")
break
xml_node.append(_create_atspi_node(ch, depth + 1, flag))
except:
except Exception:
logger.warning(
"Error occurred during children traversing. Has Ignored. Node: %s",
lxml.etree.tostring(xml_node, encoding="unicode"),
Expand Down
4 changes: 2 additions & 2 deletions gui_agents/s1/aci/MacOSACI.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def type(
try:
# Use the provided element_id or default to None
node = self.find_element(element_id) if element_id is not None else None
except:
except Exception:
node = None

if node is not None:
Expand Down Expand Up @@ -402,7 +402,7 @@ def scroll(self, element_id: int, clicks: int):
"""
try:
node = self.find_element(element_id)
except:
except Exception:
node = self.find_element(0)
# print(node.attrib)
coordinates = node["position"]
Expand Down
4 changes: 2 additions & 2 deletions gui_agents/s1/aci/WindowsOSACI.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def type(
"""
try:
node = self.find_element(element_id) if element_id is not None else None
except:
except Exception:
node = None

if node is not None:
Expand Down Expand Up @@ -386,7 +386,7 @@ def scroll(self, element_id: int, clicks: int):
"""
try:
node = self.find_element(element_id)
except:
except Exception:
node = self.find_element(0)

coordinates = node["position"]
Expand Down
12 changes: 6 additions & 6 deletions gui_agents/s1/aci/windowsagentarena/GroundingAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def linearize_and_annotate_tree(self, obs, show_all=False):
def find_element(self, element_id):
try:
selected_element = self.nodes[int(element_id)]
except:
except Exception:
print("The index of the selected element was out of range.")
selected_element = self.nodes[0]
self.index_out_of_range_flag = True
Expand Down Expand Up @@ -375,7 +375,7 @@ def type(
try:
# Use the provided element_id or default to None
node = self.find_element(element_id) if element_id is not None else None
except:
except Exception:
node = None

if node is not None:
Expand Down Expand Up @@ -432,7 +432,7 @@ def type(
# '''
# try:
# node = self.find_element(element_id)
# except:
# except Exception:
# node = self.find_element(0)
# # print(node.attrib)
# coordinates = eval(
Expand All @@ -457,7 +457,7 @@ def type(
# '''
# try:
# node = self.find_element(element_id)
# except:
# except Exception:
# node = self.find_element(0)

# self.clipboard = node.text
Expand All @@ -471,7 +471,7 @@ def type(
# '''
# try:
# node = self.find_element(element_id)
# except:
# except Exception:
# node = self.find_element(0)

# coordinates = eval(
Expand Down Expand Up @@ -547,7 +547,7 @@ def scroll(self, element_id: int, clicks: int):
"""
try:
node = self.find_element(element_id)
except:
except Exception:
node = self.find_element(0)
# print(node.attrib)
coordinates = eval(
Expand Down
2 changes: 1 addition & 1 deletion gui_agents/s1/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_char():
import msvcrt

return msvcrt.getch().decode("utf-8", errors="ignore")
except:
except Exception:
return input() # Fallback for non-terminal environments


Expand Down
4 changes: 2 additions & 2 deletions gui_agents/s1/core/AgentS.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def update_narrative_memory(self, trajectory: str) -> None:
)
try:
reflections = json.load(open(reflection_path))
except:
except Exception:
reflections = {}

if self.search_query not in reflections:
Expand Down Expand Up @@ -344,7 +344,7 @@ def update_episodic_memory(self, meta_data: Dict, subtask_trajectory: str) -> st
self.local_kb_path, self.platform, "episodic_memory.json"
)
kb = json.load(open(subtask_path))
except:
except Exception:
kb = {}
if subtask_key not in kb.keys():
subtask_summarization = self.planner.summarize_episode(
Expand Down
4 changes: 2 additions & 2 deletions gui_agents/s1/core/Knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def formulate_query(self, instruction: str, observation: Dict) -> str:
try:
with open(query_path, "r") as f:
formulate_query = json.load(f)
except:
except Exception:
formulate_query = {}

if instruction in formulate_query:
Expand Down Expand Up @@ -123,7 +123,7 @@ def _search(self, instruction: str, search_query: str, search_engine: str) -> st
try:
with open(file, "r") as f:
exist_search_results = json.load(f)
except:
except Exception:
exist_search_results = {}

if instruction in exist_search_results:
Expand Down
4 changes: 2 additions & 2 deletions gui_agents/s2/agents/agent_s.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def update_narrative_memory(self, trajectory: str) -> None:
)
try:
reflections = json.load(open(reflection_path))
except:
except Exception:
reflections = {}

if self.search_query not in reflections:
Expand Down Expand Up @@ -387,7 +387,7 @@ def update_episodic_memory(self, meta_data: Dict, subtask_trajectory: str) -> st
self.local_kb_path, self.platform, "episodic_memory.json"
)
kb = json.load(open(subtask_path))
except:
except Exception:
kb = {}
if subtask_key not in kb.keys():
subtask_summarization = self.planner.summarize_episode(
Expand Down
4 changes: 2 additions & 2 deletions gui_agents/s2/agents/grounding.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def set_cell_values(new_cell_values: dict[str, str], app_name: str = "Untitled 1
for k, v in new_cell_values.items():
try:
col, row = cell_ref_to_indices(k)
except:
except Exception:
col = row = None

if col is not None and row is not None:
Expand Down Expand Up @@ -127,7 +127,7 @@ def set_cell_values(new_cell_values: dict[str, str], app_name: str = "Untitled 1
spreadsheet = spreadsheet[0][1]

sheet = spreadsheet.Sheets.getByName(sheet_name)
except:
except Exception:
raise ValueError(f"Could not find sheet {{sheet_name}} in {{app_name}}.")

for (col, row), value in new_cell_values_idx.items():
Expand Down
2 changes: 1 addition & 1 deletion gui_agents/s2/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_char():
import msvcrt

return msvcrt.getch().decode("utf-8", errors="ignore")
except:
except Exception:
return input() # Fallback for non-terminal environments


Expand Down
8 changes: 4 additions & 4 deletions gui_agents/s2/core/knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def formulate_query(self, instruction: str, observation: Dict) -> str:
try:
with open(query_path, "r") as f:
formulate_query = json.load(f)
except:
except Exception:
formulate_query = {}

if instruction in formulate_query:
Expand Down Expand Up @@ -129,7 +129,7 @@ def _search(self, instruction: str, search_query: str, search_engine: str) -> st
try:
with open(file, "r") as f:
exist_search_results = json.load(f)
except:
except Exception:
exist_search_results = {}

if instruction in exist_search_results:
Expand Down Expand Up @@ -271,7 +271,7 @@ def save_episodic_memory(self, subtask_key: str, subtask_traj: str) -> None:

try:
kb = load_knowledge_base(self.episodic_memory_path)
except:
except Exception:
kb = {}

if subtask_key not in kb:
Expand All @@ -296,7 +296,7 @@ def save_narrative_memory(self, task_key: str, task_traj: str) -> None:

try:
kb = load_knowledge_base(self.narrative_memory_path)
except:
except Exception:
kb = {}

if task_key not in kb:
Expand Down
4 changes: 2 additions & 2 deletions gui_agents/s2_5/agents/grounding.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def set_cell_values(new_cell_values: dict[str, str], app_name: str = "Untitled 1
for k, v in new_cell_values.items():
try:
col, row = cell_ref_to_indices(k)
except:
except Exception:
col = row = None

if col is not None and row is not None:
Expand Down Expand Up @@ -127,7 +127,7 @@ def set_cell_values(new_cell_values: dict[str, str], app_name: str = "Untitled 1
spreadsheet = spreadsheet[0][1]

sheet = spreadsheet.Sheets.getByName(sheet_name)
except:
except Exception:
raise ValueError(f"Could not find sheet {{sheet_name}} in {{app_name}}.")

for (col, row), value in new_cell_values_idx.items():
Expand Down
2 changes: 1 addition & 1 deletion gui_agents/s2_5/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_char():
import msvcrt

return msvcrt.getch().decode("utf-8", errors="ignore")
except:
except Exception:
return input() # Fallback for non-terminal environments


Expand Down
4 changes: 2 additions & 2 deletions gui_agents/s3/agents/grounding.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def set_cell_values(new_cell_values: dict[str, str], app_name: str = "Untitled 1
for k, v in new_cell_values.items():
try:
col, row = cell_ref_to_indices(k)
except:
except Exception:
col = row = None

if col is not None and row is not None:
Expand Down Expand Up @@ -147,7 +147,7 @@ def set_cell_values(new_cell_values: dict[str, str], app_name: str = "Untitled 1
spreadsheet = spreadsheet[0][1]

sheet = spreadsheet.Sheets.getByName(sheet_name)
except:
except Exception:
raise ValueError(f"Could not find sheet {{sheet_name}} in {{app_name}}.")

for (col, row), value in new_cell_values_idx.items():
Expand Down
2 changes: 1 addition & 1 deletion gui_agents/s3/bbon/comparative_judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def get_final_screenshot_file(task_dir: str) -> str:
def extract_step_num(filename):
try:
return int(filename.split("_")[1].split(".")[0])
except:
except Exception:
return 0

screenshot_files.sort(key=extract_step_num)
Expand Down
2 changes: 1 addition & 1 deletion gui_agents/s3/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_char():
import msvcrt

return msvcrt.getch().decode("utf-8", errors="ignore")
except:
except Exception:
return input() # Fallback for non-terminal environments


Expand Down
2 changes: 1 addition & 1 deletion osworld_setup/s1/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def get_result(action_space, use_model, observation_type, result_dir, total_file
).read()
)
)
except:
except Exception:
all_result.append(0.0)

if not all_result:
Expand Down
2 changes: 1 addition & 1 deletion osworld_setup/s2/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def get_result(action_space, use_model, observation_type, result_dir, total_file
).read()
)
)
except:
except Exception:
all_result.append(0.0)

if not all_result:
Expand Down
2 changes: 1 addition & 1 deletion osworld_setup/s2_5/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def get_result(action_space, use_model, observation_type, result_dir, total_file
).read()
)
)
except:
except Exception:
all_result.append(0.0)

if not all_result:
Expand Down
2 changes: 1 addition & 1 deletion osworld_setup/s2_5/run_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def get_result(action_space, use_model, observation_type, result_dir, total_file
).read()
)
)
except:
except Exception:
all_result.append(0.0)

if not all_result:
Expand Down
6 changes: 3 additions & 3 deletions osworld_setup/s3/bbon/generate_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def generate_single_fact_caption(
try:
data = json.loads(trajectory_lines[i])
pyautogui_action = data.get("exec_code")
except:
except Exception:
pass

if pyautogui_action is None:
Expand Down Expand Up @@ -74,7 +74,7 @@ async def generate_fact_captions_parallel(
def extract_step_num(filename):
try:
return int(filename.split("_")[1].split(".")[0])
except:
except Exception:
return 0

screenshot_files.sort(key=extract_step_num)
Expand All @@ -90,7 +90,7 @@ def extract_step_num(filename):
try:
with open(trajectory_file, "r") as f:
trajectory_lines = f.readlines()
except:
except Exception:
pass
Comment on lines 90 to 94
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Silent except Exception: pass on trajectory file read loses the I/O error.

If open(trajectory_file) or f.readlines() fails for any reason other than a missing file (e.g., permissions, encoding), the error is silently swallowed and trajectory_lines stays empty, causing all subsequent steps to lack action data. Narrowing to OSError and adding a log line improves debuggability.

🔧 Proposed fix
         try:
             with open(trajectory_file, "r") as f:
                 trajectory_lines = f.readlines()
-        except Exception:
-            pass
+        except OSError as e:
+            print(f"Warning: could not read trajectory file {trajectory_file}: {e}")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
try:
with open(trajectory_file, "r") as f:
trajectory_lines = f.readlines()
except:
except Exception:
pass
try:
with open(trajectory_file, "r") as f:
trajectory_lines = f.readlines()
except OSError as e:
print(f"Warning: could not read trajectory file {trajectory_file}: {e}")
🧰 Tools
🪛 Ruff (0.15.2)

[error] 93-94: try-except-pass detected, consider logging the exception

(S110)


[warning] 93-93: Do not catch blind exception: Exception

(BLE001)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@osworld_setup/s3/bbon/generate_facts.py` around lines 90 - 94, Replace the
silent catch around opening/reading trajectory_file with a narrow OSError
handler: attempt the with open(trajectory_file, "r") as f: trajectory_lines =
f.readlines() block, and on failure catch except OSError as e: set
trajectory_lines = [] (or ensure it remains defined) and log the error including
trajectory_file and e (use the module/logger variable you have), rather than
using a bare except Exception: pass, so permission/IO errors are surfaced for
debugging.


# Use shared semaphore to limit concurrent judge calls
Expand Down
2 changes: 1 addition & 1 deletion osworld_setup/s3/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ def get_result(action_space, use_model, observation_type, result_dir, total_file
).read()
)
)
except:
except Exception:
all_result.append(0.0)

if not all_result:
Expand Down
Loading