From 0d25d49d1546665ed7954564926f856d4dc9fbab Mon Sep 17 00:00:00 2001 From: Alexandre Teixeira Date: Sun, 1 Nov 2026 00:44:44 +0000 Subject: [PATCH] fix(test): isolate test_tool_policy from cross-test approval gate state Ensure _patch_loop_basics disables TOOL_APPROVAL_GATE_ENABLED so routing tests in test_tool_policy run in the intended opt-out posture even when prior tests populate DATA_DIR with skills or untrusted context. Remove unnecessary forced_tools and contextual web mock workarounds. --- tests/test_tool_policy.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/test_tool_policy.py b/tests/test_tool_policy.py index 2da581c4e..fd4fb1f23 100644 --- a/tests/test_tool_policy.py +++ b/tests/test_tool_policy.py @@ -48,7 +48,7 @@ def _patch_loop_basics(monkeypatch): monkeypatch.setattr(al, "get_setting", lambda key, default=None: default, raising=False) monkeypatch.setattr(al, "get_mcp_manager", lambda: None, raising=False) monkeypatch.setattr(al, "estimate_tokens", lambda *a, **k: 10, raising=False) - monkeypatch.setattr(al, "_configured_model_tool_surface_raw", lambda *a, **k: "", raising=False) + monkeypatch.setattr("src.tool_capabilities.TOOL_APPROVAL_GATE_ENABLED", False) def test_detects_strong_guide_only_turns(): @@ -1067,8 +1067,6 @@ def test_agent_loop_policy_blocks_disabled_web_tool_call_before_execution(monkey def test_web_fetch_js_failure_exposes_private_browser_next_round(monkeypatch): _patch_loop_basics(monkeypatch) - monkeypatch.setattr(al, "_looks_like_contextual_public_web_followup", lambda *a, **k: False, raising=False) - monkeypatch.setattr(al, "_contextual_public_web_topic_text", lambda *a, **k: "", raising=False) sent_tools = [] sent_messages = [] @@ -1108,7 +1106,6 @@ def test_web_fetch_js_failure_exposes_private_browser_next_round(monkeypatch): [{"role": "user", "content": "open the official SpaceX Starship launches page"}], max_rounds=2, relevant_tools={"web_search", "web_fetch"}, - forced_tools={"web_search", "web_fetch"}, ) )