Skip to content

The agent that grows with you

fix(tools): split the merged preview/terminal bridge timeout errors into the two cases they conflate

Brooklyn Nicholson0242946697af
diff --git a/tests/tools/test_drive_preview_tool.py b/tests/tools/test_drive_preview_tool.py
index ccb4f93e49d..b4844ea9b90 100644
--- a/tests/tools/test_drive_preview_tool.py
+++ b/tests/tools/test_drive_preview_tool.py
@@ -108,3 +108,14 @@ def test_callback_failure_is_reported():
result = json.loads(ap.drive_preview_tool(action="elements", callback=_boom))
assert "renderer went away" in result["error"]
+
+
+def test_empty_answer_distinguishes_no_tab_from_a_stale_app():
+ """An empty bridge answer used to be one merged "timed out, or no window
+ answered" string that blamed a closed tab even when the pane was open on an
+ app older than this backend (#94272): the two cases need different next
+ steps (open a tab vs update the app)."""
+ result = json.loads(ap.drive_preview_tool(action="elements", callback=lambda _p: ""))
+
+ assert "no preview tab is open" in result["error"]
+ assert "older than this backend" in result["error"]
diff --git a/tests/tools/test_read_preview_tool.py b/tests/tools/test_read_preview_tool.py
index 705fe2bd268..6035e26f9b2 100644
--- a/tests/tools/test_read_preview_tool.py
+++ b/tests/tools/test_read_preview_tool.py
@@ -54,3 +54,13 @@ def test_callback_failure_is_reported():
result = json.loads(rp.read_preview_tool(callback=_boom))
assert "renderer went away" in result["error"]
+
+
+def test_empty_answer_names_both_cases_and_the_remedy():
+ """Nothing-open and bridge-timeout arrive as the same empty answer; the
+ error must tell them apart (open a page vs update an older app, #94272)."""
+ result = json.loads(rp.read_preview_tool(callback=lambda **_: ""))
+
+ assert "open a page with open_preview" in result["error"]
+ assert "timed out" in result["error"]
+ assert "older than this backend" in result["error"]
diff --git a/tools/annotate_preview_tool.py b/tools/annotate_preview_tool.py
index 847fbacc822..a69d46f24d2 100644
--- a/tools/annotate_preview_tool.py
+++ b/tools/annotate_preview_tool.py
@@ -39,7 +39,10 @@ def annotate_preview_tool(
except Exception as exc:
return tool_error(f"Failed to annotate the in-app browser: {exc}")
if not raw:
- return tool_error("The annotation timed out, or no GUI window answered. Open a page with open_preview first.")
+ return tool_error(
+ "No GUI window answered with a page: no preview tab is open. "
+ "Open a page with open_preview first. If the pane IS open, the desktop app "
+ "may be older than this backend — its bridge-unavailable error names that case.")
try:
return json.dumps(json.loads(raw), ensure_ascii=False)
except (TypeError, ValueError):
diff --git a/tools/drive_preview_tool.py b/tools/drive_preview_tool.py
index 68ad97fa9d7..c21f7e21806 100644
--- a/tools/drive_preview_tool.py
+++ b/tools/drive_preview_tool.py
@@ -54,7 +54,10 @@ def drive_preview_tool(
except Exception as exc:
return tool_error(f"Failed to act on the in-app browser: {exc}")
if not raw:
- return tool_error("The action timed out, or no GUI window answered. Open a page with open_preview first.")
+ return tool_error(
+ "No GUI window answered with a page: no preview tab is open. "
+ "Open a page with open_preview first. If the pane IS open, the desktop app "
+ "may be older than this backend — its bridge-unavailable error names that case.")
return passthrough_json(raw)
diff --git a/tools/read_preview_tool.py b/tools/read_preview_tool.py
index 68e3f63b931..c8f48b4f848 100644
--- a/tools/read_preview_tool.py
+++ b/tools/read_preview_tool.py
@@ -20,4 +20,6 @@ def read_preview_tool(
"read_preview is only available in the Hermes desktop app.",
"start and count must be integers.",
"Failed to read the preview pane: ",
- "No preview tab is open, or the read timed out."))
+ "No preview tab answered: nothing is open (open a page with open_preview), "
+ "or the bridge timed out. If the pane IS open, the desktop app may be older "
+ "than this backend — update it and retry."))
diff --git a/tools/read_terminal_tool.py b/tools/read_terminal_tool.py
index 41087a907d5..8e1ce2c9150 100644
--- a/tools/read_terminal_tool.py
+++ b/tools/read_terminal_tool.py
@@ -42,7 +42,9 @@ def read_terminal_tool(
"read_terminal is only available in the Hermes desktop app.",
"start_line and count must be integers.",
"Failed to read terminal: ",
- "No in-app terminal is open, or the read timed out.",
+ "No in-app terminal answered: nothing is open, or the bridge timed out. "
+ "If the terminal pane IS open, the desktop app may be older than this "
+ "backend — update it and retry.",
))