From 913c4943edcb0ee3060cdb759262b0127d6a1924 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Wed, 18 Nov 2026 08:37:14 +0000 Subject: [PATCH] feat(batch): spawned workers and close-outs run Opus at medium effort session_command and closeout_command pass --model opus --effort medium (WORKER_MODEL/WORKER_EFFORT); CLOSEOUT_MODEL follows WORKER_MODEL. Shift workers had no --model or --effort and inherited the CLI default (high). MODEL_DELEGATION.md: Anthropic execution workers default to Opus medium. Fable 5.2 review: three lows (stale argv in batch AGENTS.md, live test argv, a vacuous assert), fixed; live claude --bg spawn with the flags passed. Closes #672 Co-Authored-By: Claude Opus 5.5 --- AUTONOMY.md | 4 ++- agents/conductors/batch/AGENTS.md | 5 ++-- agents/conductors/batch/_orchestrator.py | 20 +++++++++----- skills/MODEL_DELEGATION.md | 4 +++ tests/test_orchestrator_closeout.py | 4 +-- tests/test_orchestrator_dispatch.py | 1 + tests/test_worker_model_effort.py | 34 ++++++++++++++++++++++++ 7 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 tests/test_worker_model_effort.py diff --git a/AUTONOMY.md b/AUTONOMY.md index 687af2ae..09e9ec0d 100644 --- a/AUTONOMY.md +++ b/AUTONOMY.md @@ -935,7 +935,9 @@ the exemption it runs under is `PyAutoMind/policy/shift_watcher.md`). remain before `review-at:`, so an answer given from the phone can restart it in-shift (human-approved 2026-11-17, M3.6c, PyAutoBrain#669). It starts worker sessions (`claude --bg`, phase 3b) — that is dispatch, ruled - by "Shift briefs and unattended `glance`", not a network read. + by "Shift briefs and unattended `glance`", not a network read. Workers and + close-outs start as Opus at medium effort (`WORKER_MODEL`/`WORKER_EFFORT`, + PyAutoBrain#672). - **Opt-in and laptop-only.** It runs only from a systemd user timer the human installs, only while a brief is open, and never while `STOP` exists. No conductor, faculty or skill calls it; no session arms it. diff --git a/agents/conductors/batch/AGENTS.md b/agents/conductors/batch/AGENTS.md index 8c029355..d3063303 100644 --- a/agents/conductors/batch/AGENTS.md +++ b/agents/conductors/batch/AGENTS.md @@ -351,7 +351,8 @@ worker "blocked on a person". It is kept in `counters["login"]` and in the tick's result. **Real workers (phase 3b).** Without `PYAUTO_ORCHESTRATOR_FAKE=1` each spawn is -`claude --bg --name shift: --permission-mode `, the +`claude --bg --name shift: --model opus --effort medium --permission-mode + ` (`WORKER_MODEL`/`WORKER_EFFORT`, PyAutoBrain#672), the prompt filled from `worker_template.md` (the `/start_dev --auto` line, the end-at-deliverable contract, the brief path, "never commit to PyAutoMind yourself", and the `/.done` marker). The lease records the short @@ -507,7 +508,7 @@ shift is not shadow, `review-at:` is more than 20 minutes away, spend is under 1.5× `token-budget:` (#632; AUTONOMY.md "Close-out budget — 2026-11-14"), and — last — a merge slot is free under `merge-cap:` (`_merge_slots.py`; a worker's in-turn merge takes from the same count). Then it starts **one** close-out session -(`closeout_template.md`; `claude --bg --name shift-close: --model opus`). +(`closeout_template.md`; `claude --bg --name shift-close: --model opus --effort medium`). That session is the independent leg: it runs the `Witness:` itself, reviews the diff adversarially, checks the `decision-taken` label and Heart, and only then runs the `/prm` close-out — or refuses. A merge marks the PR merged; a `glance` one also bumps `glance_auto_merges` diff --git a/agents/conductors/batch/_orchestrator.py b/agents/conductors/batch/_orchestrator.py index b177f98a..45ba19c7 100644 --- a/agents/conductors/batch/_orchestrator.py +++ b/agents/conductors/batch/_orchestrator.py @@ -87,10 +87,16 @@ #: The worker prompt every real worker starts from (never a bare session). WORKER_TEMPLATE = Path(__file__).with_name("worker_template.md") CLOSEOUT_TEMPLATE = Path(__file__).with_name("closeout_template.md") +#: The model and effort every spawned worker starts on — the human's ruling of +#: 2026-11-18 (PyAutoBrain#672): Opus at medium effort, whatever the effort of +#: the session that composed the shift. +WORKER_MODEL = "opus" +WORKER_EFFORT = "medium" #: The close-out session's model (phase 4b). The same model as the workers — #: the human's call 2026-11-04 (AUTONOMY.md "Stage-2 adversary amendment"): a -#: fresh, independent session that runs the witness itself is the leg. -CLOSEOUT_MODEL = "opus" +#: fresh, independent session that runs the witness itself is the leg. Its +#: effort follows the workers too (2026-11-18). Stage-2 rows record this name. +CLOSEOUT_MODEL = WORKER_MODEL STAGE2_HEADING = "## Unattended `glance` sub-window (stage 2)" #: A merged close-out that did not say what became of the task's worktree. CLEANUP_UNREPORTED = ("not reported by the close-out — check for a worktree left " @@ -349,12 +355,12 @@ def closeout_prompt(task: str, pr_url: str, prompt_path: str, brief_path: Path, def closeout_command(task: str, pr_url: str, prompt_path: str, brief_path: Path, lease_dir: Path, mode: str) -> list[str]: """The argv that starts one close-out session: its own name, the close-out - model, the brief's worker mode.""" + model at the workers' effort, the brief's worker mode. The prompt is last.""" if mode not in _brief.WORKER_MODES: raise OrchestratorError(f"worker mode {mode!r} is not one of " + ", ".join(_brief.WORKER_MODES)) return ["claude", "--bg", "--name", f"shift-close:{task}", "--model", CLOSEOUT_MODEL, - "--permission-mode", mode, + "--effort", WORKER_EFFORT, "--permission-mode", mode, closeout_prompt(task, pr_url, prompt_path, brief_path, lease_dir)] @@ -386,14 +392,16 @@ def worker_env(lease_dir: Path, base: dict | None = None) -> dict: def session_command(task: str, prompt_path: str, brief_path: Path, lease_dir: Path, mode: str, redispatch: bool = False, resume: dict | None = None) -> list[str]: - """The exact argv that starts one worker — named, moded, templated. + """The exact argv that starts one worker — named, on `WORKER_MODEL` at + `WORKER_EFFORT`, moded, templated; the prompt is the last element. No `--session-id`: `claude --bg` (2.1.316) assigns its own, so the worker is tracked by the short id the launch prints.""" if mode not in _brief.WORKER_MODES: raise OrchestratorError(f"worker mode {mode!r} is not one of " + ", ".join(_brief.WORKER_MODES)) - return ["claude", "--bg", "--name", f"shift:{task}", "--permission-mode", mode, + return ["claude", "--bg", "--name", f"shift:{task}", "--model", WORKER_MODEL, + "--effort", WORKER_EFFORT, "--permission-mode", mode, worker_prompt(task, prompt_path, brief_path, lease_dir, redispatch, resume)] diff --git a/skills/MODEL_DELEGATION.md b/skills/MODEL_DELEGATION.md index f7f73c6f..5fef4d0a 100644 --- a/skills/MODEL_DELEGATION.md +++ b/skills/MODEL_DELEGATION.md @@ -85,6 +85,10 @@ missing phase. - Request concise results: changed files, pass/fail counts, and only the decision-relevant tail of a failure. - Keep full logs in a file or harness transcript, not chat. +- Anthropic execution workers (Agent-tool subagents, shift workers, shift + close-outs) run Opus at medium effort unless the human asks otherwise, + whatever the session's own effort. An independent reviewer on another model + leaves effort unset. - Do not rerun an unchanged successful check unless inputs or its gate changed. - Prefer native completion events. Do not repeatedly poll unchanged pending state or agent lists; use bounded waits only when needed, and never arm a diff --git a/tests/test_orchestrator_closeout.py b/tests/test_orchestrator_closeout.py index 5c53e3fb..63df66cb 100644 --- a/tests/test_orchestrator_closeout.py +++ b/tests/test_orchestrator_closeout.py @@ -393,8 +393,8 @@ def boom(mind): def test_closeout_command_is_named_moded_and_on_the_closeout_model(tmp_path): argv = orch.closeout_command("t1", PR1, "draft/x/t1.md", tmp_path / "b.md", tmp_path / "leases", "auto") - assert argv[:8] == ["claude", "--bg", "--name", "shift-close:t1", "--model", "opus", - "--permission-mode", "auto"] + assert argv[:10] == ["claude", "--bg", "--name", "shift-close:t1", "--model", "opus", + "--effort", "medium", "--permission-mode", "auto"] prompt = argv[-1] assert PR1 in prompt and "run it yourself" in prompt assert str(tmp_path / "leases" / "t1.closeout") in prompt diff --git a/tests/test_orchestrator_dispatch.py b/tests/test_orchestrator_dispatch.py index 758975ad..1f1db9a9 100644 --- a/tests/test_orchestrator_dispatch.py +++ b/tests/test_orchestrator_dispatch.py @@ -383,6 +383,7 @@ def test_live_sandbox_worker(): yields a non-zero token count. Removed afterwards.""" import time res = subprocess.run(["claude", "--bg", "--name", "shift:live-witness", + "--model", orch.WORKER_MODEL, "--effort", orch.WORKER_EFFORT, "--permission-mode", "auto", "Reply with the single word DONE and stop."], cwd=_trusted_root(), capture_output=True, text=True, diff --git a/tests/test_worker_model_effort.py b/tests/test_worker_model_effort.py new file mode 100644 index 00000000..b1c8d7fb --- /dev/null +++ b/tests/test_worker_model_effort.py @@ -0,0 +1,34 @@ +"""Spawned workers and close-outs start as Opus at medium effort (PyAutoBrain#672).""" +import sys +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +from test_orchestrator_digest import orch # noqa: E402 + +PR = "https://github.com/example-org/PyAutoBrain/pull/1" + + +def _flag(argv, name): + return argv[argv.index(name) + 1] + + +def test_the_worker_defaults_are_opus_at_medium_and_closeouts_follow(): + assert orch.WORKER_MODEL == "opus" + assert orch.WORKER_EFFORT == "medium" + assert orch.CLOSEOUT_MODEL == orch.WORKER_MODEL + + +def test_the_worker_argv_carries_model_and_effort_with_the_prompt_last(tmp_path: Path): + argv = orch.session_command("t1", "draft/x/t1.md", tmp_path / "shift.md", + tmp_path / "leases", "auto") + assert argv[:10] == ["claude", "--bg", "--name", "shift:t1", "--model", "opus", + "--effort", "medium", "--permission-mode", "auto"] + assert "Use the start-dev skill. draft/x/t1.md --auto" in argv[-1] + + +def test_the_closeout_argv_carries_model_and_effort_with_the_prompt_last(tmp_path: Path): + argv = orch.closeout_command("t1", PR, "draft/x/t1.md", tmp_path / "b.md", + tmp_path / "leases", "auto") + assert _flag(argv, "--model") == "opus" + assert _flag(argv, "--effort") == "medium" + assert PR in argv[-1]