Skip to content

The agent that grows with you

fix(approval): approvals.mode off bypasses the shared action gate (computer_use prompts)

teknium198a3324821c6
diff --git a/tests/tools/test_request_tool_approval.py b/tests/tools/test_request_tool_approval.py
index 51b6e539e0c..29fd459bcb8 100644
--- a/tests/tools/test_request_tool_approval.py
+++ b/tests/tools/test_request_tool_approval.py
@@ -182,3 +182,20 @@ class TestRequestToolApproval:
)
res = request_tool_approval("terminal", "curl PUT", rule_key="ext")
assert res == {"approved": True, "message": None}
+
+ def test_approvals_mode_off_bypasses_gate(self, monkeypatch):
+ """``approvals.mode: off`` (the Desktop "Approvals: off" toggle) must bypass the shared gate
+ exactly like the shell guards do — otherwise computer_use / plugin-rule / SSH-config-write
+ approvals keep prompting a user who turned approvals off."""
+ monkeypatch.setattr(approval_context, "_get_approval_mode", lambda: "off")
+ monkeypatch.setattr(approval, "_is_interactive_cli", lambda: True)
+ monkeypatch.setattr(
+ approval, "prompt_dangerous_approval",
+ lambda *a, **k: pytest.fail("approvals.mode=off must not prompt"),
+ )
+ monkeypatch.setattr(
+ approval_prompt, "prompt_dangerous_approval",
+ lambda *a, **k: pytest.fail("approvals.mode=off must not prompt"),
+ )
+ res = request_tool_approval("computer_use", "click", rule_key="cua")
+ assert res == {"approved": True, "message": None}
diff --git a/tools/approval.py b/tools/approval.py
index 058d71c302e..c0ca4e4670c 100644
--- a/tools/approval.py
+++ b/tools/approval.py
@@ -885,7 +885,10 @@ def _run_approval_gate(
an explicit ``*_deny_message`` (the file-tool write gates word their own).
"""
# Hardline blocks are the caller's job BEFORE this gate, so yolo here only skips the recoverable approval layer.
- if _yolo_active():
+ # ``approvals.mode: off`` is the third bypass source (the Desktop "Approvals: off" toggle writes it); the shell
+ # guards honour it, so every action routed through this gate (computer_use, plugin rules, SSH-config writes,
+ # dangerous-pattern prompts) must too, or "off" still prompts on those surfaces.
+ if _yolo_active() or approval_context._get_approval_mode() == "off":
return _approved()
session_key = get_current_session_key()
if is_approved(session_key, pattern_key):