Skip to content

The agent that grows with you

fix(tools): pass single_query_deny_message to the ssh-config write approval gate

thenabbuacf82456077b
diff --git a/tests/tools/test_file_tools.py b/tests/tools/test_file_tools.py
index 9502eae3505..068b3d9f2b6 100644
--- a/tests/tools/test_file_tools.py
+++ b/tests/tools/test_file_tools.py
@@ -1000,3 +1000,36 @@ class TestNotFoundCache:
assert _check_not_found_cache("read", "/tmp/never-exists-notify", tid) is None, (
"notify_other_tool_call must clear cached misses"
)
+
+
+class TestSSHConfigWriteGateSingleQuery:
+ """Regression: the ssh-config write guard must pass
+ single_query_deny_message to _run_approval_gate (required kwarg since
+ 1596148ff). Missing it raises TypeError instead of routing through the
+ approval flow — see issue #93201."""
+
+ def test_gate_call_passes_single_query_deny_message(self):
+ import inspect as _inspect
+ import re as _re
+ import tools.file_tools as ft
+
+ src = _inspect.getsource(ft)
+ idx = src.find("_approval._run_approval_gate(")
+ assert idx != -1, "ssh_config_write gate call not found"
+ block = src[idx:idx + 900]
+ assert "pattern_key=\"ssh_config_write\"" in block
+
+ from tools.approval import _run_approval_gate
+ required = [
+ name for name, param in _inspect.signature(
+ _run_approval_gate).parameters.items()
+ if param.kind == _inspect.Parameter.KEYWORD_ONLY
+ and param.default is _inspect.Parameter.empty
+ ]
+ missing = [k for k in required if not _re.search(
+ rf"\b{k}\s*=", block)]
+ assert missing == [], (
+ f"_run_approval_gate call at ssh_config_write gate is missing "
+ f"required kwargs {missing}; it would raise TypeError instead "
+ f"of showing an approval prompt"
+ )
diff --git a/tools/file_tools.py b/tools/file_tools.py
index 0a535575a69..c54cb687f74 100644
--- a/tools/file_tools.py
+++ b/tools/file_tools.py
@@ -1010,8 +1010,10 @@ def _check_approval_required_write(paths: list[str],
cron_deny_message=blocked.format(
why="requires approval but this cron session denies it."),
single_query_deny_message=blocked.format(
- why="requires approval but single-query mode (-q) runs without "
- "a user present to approve it."),
+ why="requires approval but single-query (-q) sessions run "
+ "without a user present to approve it. To allow flagged "
+ "actions in single-query mode, set approvals.single_query_mode: "
+ "approve in config.yaml."),
autoapprove_log_prefix="ssh_config_write",
fail_closed_when_no_human=True,
no_human_block_message=blocked.format(