fix(grok): auto-approve tool execution (--always-approve) so headless agents can call tools

Live smoke caught every grok agent (Main PM, pr-reviewer, dev, …) ending its run
with stopReason=Cancelled and empty output the instant it reached for a tool. Root
cause: headless `grok -p` cannot approve a tool call without `--always-approve`
(grok's docs: required for unattended automation), and the per-role args didn't
pass it — so no agent could call a gateway verb, an edit, or an MCP tool, and the
run was cancelled.

Add `--always-approve` to grok_cli_args_for_role (one place → every role, one-shot
and interactive). Safety is unaffected: `--disallowed-tools` still removes tools
and `--deny` still hard-blocks command patterns regardless of approval (a denied
command returns a permission error and the agent recovers — verified live).

Proven in the rebuilt image side-by-side: without the flag a tool call yields
Cancelled/not-called; with the real rendered args it returns EndTurn and the MCP
tool actually runs. (My earlier in-image tool-calling check passed `--always-approve`
manually, which masked that the production args omitted it — fixed.)
This commit is contained in:
Renn F
2026-06-19 07:02:01 +02:00
parent 9a4af47b9a
commit 58fd78830c
2 changed files with 18 additions and 3 deletions
@@ -113,6 +113,13 @@ def test_web_search_disabled_for_every_role() -> None:
assert "--disable-web-search" in gc.grok_cli_args_for_role(role)
def test_every_role_auto_approves_tools() -> None:
# Headless `grok -p` cannot approve a tool call without this; without it the
# run ends Cancelled the moment the agent calls a gateway verb / MCP tool.
for role in ("developer", "prompter", "secretary", "main_pm", "pr_reviewer", "qa"):
assert "--always-approve" in gc.grok_cli_args_for_role(role)
def test_effort_is_fleet_override_only(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("ROBOCO_GROK_REASONING_EFFORT", "high")
args = gc.grok_cli_args("be-dev-1")