Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion AUTONOMY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions agents/conductors/batch/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:<task> --permission-mode <worker-mode> <prompt>`, the
`claude --bg --name shift:<task> --model opus --effort medium --permission-mode
<worker-mode> <prompt>` (`WORKER_MODEL`/`WORKER_EFFORT`, PyAutoBrain#672), the
prompt filled from `worker_template.md` (the `/start_dev <path> --auto` line,
the end-at-deliverable contract, the brief path, "never commit to PyAutoMind
yourself", and the `<lease>/<task>.done` marker). The lease records the short
Expand Down Expand Up @@ -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:<task> --model opus`).
(`closeout_template.md`; `claude --bg --name shift-close:<task> --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`
Expand Down
20 changes: 14 additions & 6 deletions agents/conductors/batch/_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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)]


Expand Down Expand Up @@ -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)]


Expand Down
4 changes: 4 additions & 0 deletions skills/MODEL_DELEGATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_orchestrator_closeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/test_orchestrator_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
34 changes: 34 additions & 0 deletions tests/test_worker_model_effort.py
Original file line number Diff line number Diff line change
@@ -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]
Loading