Skip to content
Python

run: the approval mode that asks is named ask

Rohit C Prasad14e5e8195ff9
diff --git a/coworker/headless/runner.py b/coworker/headless/runner.py
index 540cb500..55e2acfd 100644
--- a/coworker/headless/runner.py
+++ b/coworker/headless/runner.py
@@ -40,14 +40,20 @@ import uuid
from pathlib import Path
from typing import Any, Optional
-MODES = [
- "bypass-approvals",
- "dangerously-bypass-approvals",
- "auto-approve",
- "interactive",
- "custom",
- "auto", # legacy spelling of bypass-approvals
-]
+# How tool calls are approved. `ask` is the app's "Ask for approval"; the engine stores
+# it as "interactive".
+MODES = ["ask", "auto-approve", "bypass-approvals", "dangerously-bypass-approvals"]
+# Accepted but unlisted: the stored name of `ask`, and older spellings a harness may pass.
+_MODE_STORED = {"ask": "interactive", "interactive": "interactive", "custom": "custom", "auto": "auto"}
+
+
+def _mode_arg(value: str) -> str:
+ name = value.strip().lower()
+ if name in MODES or name in _MODE_STORED:
+ return _MODE_STORED.get(name, name)
+ raise argparse.ArgumentTypeError(f"unknown mode {value!r} (choose from {', '.join(MODES)})")
+
+
ATTENDANCE = ["auto"] # `inbox` needs the server's Inbox; `attended` needs a screen
RETRY_DELAYS_ENV = "OPENWORKER_RUN_RETRY_DELAYS"
@@ -87,7 +93,10 @@ def parse_args(argv: Optional[list[str]] = None) -> argparse.Namespace:
)
# The flag's first name; kept so an existing harness command still works.
p.add_argument("--persona", dest="persona", default=argparse.SUPPRESS, help=argparse.SUPPRESS)
- p.add_argument("--mode", default="bypass-approvals", choices=MODES)
+ p.add_argument(
+ "--mode", default="bypass-approvals", type=_mode_arg, metavar="MODE",
+ help="how tool calls are approved: " + ", ".join(MODES) + " (default: bypass-approvals)",
+ )
p.add_argument(
"--attendance",
default="auto",
diff --git a/docs/headless.md b/docs/headless.md
index c51d647e..9fda6ac8 100644
--- a/docs/headless.md
+++ b/docs/headless.md
@@ -23,7 +23,7 @@ in the Inbox, or supplied by the engine. That is the *attendance* setting.
| Mode | Routine tool calls | The safety checks (run a downloaded file, write outside the workspace, edit git hooks / CI / settings files, grant authority that outlives the session) |
|---|---|---|
-| `interactive` | asks | asks |
+| `ask` | asks | asks |
| `auto-approve` | the reviewer decides; anything it is unsure about asks | asks |
| `bypass-approvals` | runs | asks |
| `dangerously-bypass-approvals` | runs | runs, each one recorded as "cleared by mode" |
diff --git a/tests/test_headless_run.py b/tests/test_headless_run.py
index c3653815..6638e1eb 100644
--- a/tests/test_headless_run.py
+++ b/tests/test_headless_run.py
@@ -13,6 +13,8 @@ import subprocess
import sys
from pathlib import Path
+import pytest
+
ROOT = Path(__file__).resolve().parents[1]
SCRIPT = [
@@ -130,10 +132,10 @@ def test_bypass_writes_the_file_and_leaves_a_full_record(tmp_path: Path) -> None
assert "tool_calls" not in s and "metrics" not in s and "model_name" not in s
-def test_interactive_refuses_the_card_nobody_can_answer_and_records_it(tmp_path: Path) -> None:
+def test_ask_refuses_the_card_nobody_can_answer_and_records_it(tmp_path: Path) -> None:
# Also an unpriced model (cost must be null, never guessed) in the two-slash form,
# which must split on the first slash only.
- proc, ws, out = _run(tmp_path, "interactive", model="together/deepseek-ai/DeepSeek-V4-Pro")
+ proc, ws, out = _run(tmp_path, "ask", model="together/deepseek-ai/DeepSeek-V4-Pro")
assert proc.returncode == 0, proc.stdout + proc.stderr
assert not (ws / "hello.txt").exists()
summary = _summary(out)
@@ -425,3 +427,14 @@ def test_an_empty_standard_input_stops_the_run(tmp_path: Path) -> None:
assert "--prompt" in proc.stderr
assert not (out / "summary.json").exists()
+
+def test_the_stored_mode_name_is_still_accepted_and_an_unknown_one_is_not(tmp_path: Path) -> None:
+ from coworker.headless.runner import parse_args
+
+ base = ["--prompt", "x", "--model", "anthropic/claude-sonnet-5", "--out", str(tmp_path)]
+ assert parse_args([*base, "--mode", "ask"]).mode == "interactive"
+ assert parse_args([*base, "--mode", "interactive"]).mode == "interactive"
+ assert parse_args([*base, "--mode", "auto-approve"]).mode == "auto-approve"
+ with pytest.raises(SystemExit):
+ parse_args([*base, "--mode", "plan"])
+