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.
This commit is contained in:
Alexandre Teixeira
2026-11-01 00:44:44 +00:00
parent bafb7949f8
commit 0d25d49d15
+1 -4
View File
@@ -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"},
)
)