The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(tools): pin open_preview missing-path emit (#95853)
Paula Rossi934b2b94cc81
diff --git a/tests/tools/test_open_preview_tool.py b/tests/tools/test_open_preview_tool.pyindex 2c852d750e6..d1aac2d6156 100644--- a/tests/tools/test_open_preview_tool.py+++ b/tests/tools/test_open_preview_tool.py@@ -80,3 +80,14 @@ def test_file_uri_directory_is_an_error(tmp_path):assert "error" in resultassert "director" in result["error"].lower()assert emitted == []+++def test_missing_path_still_emits(tmp_path):+ """Reject only existing directories — a missing path is the renderer's call."""+ emitted = _capture_emits()+ missing = tmp_path / "no-such-folder"++ result = json.loads(op.open_preview_tool(str(missing)))++ assert result["success"] is True+ assert emitted == [("preview.open", {"url": str(missing), "label": ""})]diff --git a/tools/open_preview_tool.py b/tools/open_preview_tool.pyindex c026a5b1288..486be94c88b 100644--- a/tools/open_preview_tool.py+++ b/tools/open_preview_tool.py@@ -61,6 +61,9 @@ def _is_existing_directory(target: str) -> bool:try:return path.is_dir()except OSError:+ # Stat failed (permissions, broken reparse, etc.). Do not treat that+ # as "this is a directory" — reject only when we positively observe+ # an existing directory. The renderer still sees the original target.return False