The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(cua): pin PATH-preservation contract, not byte equality
Teknium3e3e6f94a030
diff --git a/tests/computer_use/test_cua_cli_fallback_env.py b/tests/computer_use/test_cua_cli_fallback_env.pyindex 32aa01413eb..b006682391e 100644--- a/tests/computer_use/test_cua_cli_fallback_env.py+++ b/tests/computer_use/test_cua_cli_fallback_env.py@@ -53,6 +53,8 @@ def test_cli_fallback_strips_provider_secret_from_subprocess_env(monkeypatch):assert captured["env"] is not None, "subprocess.run must receive an explicit env="assert "ANTHROPIC_API_KEY" not in captured["env"]# Sanitization filters secrets, not everything — an ordinary var survives.- assert captured["env"].get("PATH") == "/usr/bin:/bin"+ # Original PATH entries are preserved; the hermes console-script dir may+ # be prepended (see _sanitize_subprocess_env, issue #92998).+ assert captured["env"].get("PATH", "").endswith("/usr/bin:/bin")diff --git a/tests/computer_use/test_cua_spawn_env_sanitization.py b/tests/computer_use/test_cua_spawn_env_sanitization.pyindex 038f052e1ce..2dfd12376c0 100644--- a/tests/computer_use/test_cua_spawn_env_sanitization.py+++ b/tests/computer_use/test_cua_spawn_env_sanitization.py@@ -14,6 +14,7 @@ full parent environment (provider API keys included):"""import json+import osfrom unittest.mock import MagicMockSECRET = "sk-super-secret-should-not-leak"@@ -42,11 +43,24 @@ def _assert_sanitized(captured):assert env is not None, "subprocess must receive an explicit env="assert "ANTHROPIC_API_KEY" not in env# Sanitization filters secrets, not everything — ordinary vars survive.- assert env.get("PATH") == "/usr/bin:/bin"+ _assert_path_preserved(env)# Confirms the telemetry helper still ran (default: telemetry disabled).assert env.get("CUA_DRIVER_RS_TELEMETRY_ENABLED") == "0"+def _assert_path_preserved(env):+ """Original PATH entries survive sanitization; the hermes console-script+ dir may be prepended (see _sanitize_subprocess_env, issue #92998) so we+ assert the contract, not byte equality."""+ from tools.environments.local import _resolve_hermes_bin_dir++ path_val = env.get("PATH", "")+ assert path_val.endswith("/usr/bin:/bin"), path_val+ hermes_bin = _resolve_hermes_bin_dir()+ if hermes_bin and path_val != "/usr/bin:/bin":+ assert path_val.startswith(hermes_bin + os.pathsep), path_val++def _patch_windows_hide_flags(monkeypatch, module):"""Pin the ``windows_hide_flags()`` seam so the console-hiding assertionis host-independent.@@ -211,7 +225,7 @@ def test_doctor_sanitized_env_helper(monkeypatch):env = doctor._sanitized_cua_env()assert "ANTHROPIC_API_KEY" not in env- assert env.get("PATH") == "/usr/bin:/bin"+ _assert_path_preserved(env)assert env.get("CUA_DRIVER_RS_TELEMETRY_ENABLED") == "0"# The Popen spawn site must actually use the sanitized helper.