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: 2 additions & 2 deletions agents/conductors/batch/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ pin that and record every process a full brief run starts.

`bin/orchestrator_watch.py --brief <record> --mind <PyAutoMind>` runs **one
tick**: `STOP` first, then the open-brief gate, the tick lock, the lease reap,
the plan inside the brief, the caps (`max-workers:`, default 2;
`max-sessions:`, default 6) and an exclusive-create lease per spawn. The plan
the plan inside the brief, the caps (`max-workers:`, default 4;
`max-sessions:`, default 8) and an exclusive-create lease per spawn. The plan
is checked against Mind `origin/main` (#632): a draft not under its `draft/` or
claimed in its `active.md` is excluded unless this shift picked it, read from the
local `origin/main` ref after one `git fetch` per shift through the one Mind
Expand Down
2 changes: 1 addition & 1 deletion agents/conductors/batch/_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3273,7 +3273,7 @@ def _main_watch(a) -> int:
#: `merge-cap: 0` is the safe one: nothing merges unattended until raised.
NEW_BRIEF_DEFAULTS = {"review-minutes": str(DEFAULT_REVIEW_BUDGET),
"lanes": "any", "merge-cap": "0",
"token-budget": "2000000"}
"token-budget": "5000000"}


def _last_brief_goals(mind: Path) -> tuple[str, list[str]] | None:
Expand Down
2 changes: 1 addition & 1 deletion agents/conductors/batch/_brief.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

BACKLOG_POLICIES = ("none", "fill-idle", "scoped")
#: Optional usage caps (phase 3a) and their defaults when a brief omits them.
CAP_DEFAULTS = {"max-workers": 2, "max-sessions": 6}
CAP_DEFAULTS = {"max-workers": 4, "max-sessions": 8}
#: Permission modes a real worker may run in (phase 3b). `auto` is the default
#: the human chose 2026-11-03: a worker that still needs a person shows
#: `blocked` and is parked. `bypassPermissions` is never a worker mode.
Expand Down
11 changes: 11 additions & 0 deletions tests/test_batch_brief_goals.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ def test_new_prints_to_stdout_by_default_and_never_writes_a_record(tmp_path, cap
"writing a record is the dispatch — the human's act, not this verb's"


def test_new_writes_the_5m_token_budget_and_leaves_the_caps_to_the_code(tmp_path, capsys):
"""PyAutoBrain#656 Witness: `brief --new` carries `token-budget: 5000000`
and no `max-workers:` line, so a new shift gets the code default of 4."""
mind = _mind(tmp_path)
assert _batch.main(["brief", "--new", "2026-11-14-pm", "--review-at",
"2099-01-01T12:00Z", "--mind", str(mind)]) == 0
out = capsys.readouterr().out
assert " - token-budget: 5000000\n" in out
assert "max-workers:" not in out and "max-sessions:" not in out


def test_goals_without_epics_or_tags_fill_idle(tmp_path):
mind = _mind(tmp_path, "# Goals\n\n## 1. Ship it\n")
text = _batch.new_brief(mind, "2026-11-14-am", "2099-01-01T12:00Z")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_batch_watch.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_live_snapshot_shows_every_task_state_reason_health_and_budget(tmp_path)
assert "- parked — parked: awaiting-input" in text
assert "- crashed — crashed — awaiting re-dispatch" in text
assert "- workers: 2 live of 3" in text
assert "- sessions: 4 of 6" in text # the max-sessions default
assert "- sessions: 4 of 8" in text # the max-sessions default (PyAutoBrain#656)
assert "- tokens: 1234 of 5000" in text
assert "- merges: 1 of 2 (1 unattended)" in text
assert "- workers crashed: 1" in text
Expand Down
1 change: 1 addition & 0 deletions tests/test_batch_watch_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
- backlog: none
- review-minutes: 45
- lanes: any
- max-workers: 2
- merge-cap: 2
- token-budget: 400000
"""
Expand Down
18 changes: 14 additions & 4 deletions tests/test_orchestrator_steering.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,13 @@ def _merge_cap(n: int):
return lambda text: text.replace(" - merge-cap: 0\n", f" - merge-cap: {n}\n")


#: The /cap tests read their acks against the brief's own caps, so the brief
#: names them rather than leaning on the code defaults (PyAutoBrain#656).
CAP_LINES = " - max-workers: 2\n - max-sessions: 6\n"


def _cap_shift(tmp_path, monkeypatch, names=("t1",), merge_cap=2):
mind, brief, home, slot = _shift(tmp_path, monkeypatch, names=names)
mind, brief, home, slot = _shift(tmp_path, monkeypatch, names=names, extra=CAP_LINES)
brief.write_text(_merge_cap(merge_cap)(brief.read_text()))
return mind, brief, home, slot

Expand Down Expand Up @@ -638,6 +643,11 @@ def test_cap_tokens_takes_k_and_m_and_lowers_the_spawn_budget(tmp_path, monkeypa
"""


def _two_workers(text):
"""Name `max-workers: 2` in the brief, so an /add ack reads the brief's cap."""
return text.replace(" - backlog: none\n", " - backlog: none\n - max-workers: 2\n")


def _add_shift(tmp_path, monkeypatch, drafts=(), active="", brief_edit=None):
"""A git-backed shift (`t1` named) whose Mind origin/main gains `drafts`
— (path, target, lane) — from another clone after the first tick, so only
Expand Down Expand Up @@ -674,7 +684,7 @@ def publish():

def test_add_makes_a_draft_filed_mid_shift_a_named_task_and_starts_it(tmp_path, monkeypatch):
mind, brief, home, slot, publish = _add_shift(
tmp_path, monkeypatch, drafts=[(X, LIB, "local-dev")])
tmp_path, monkeypatch, drafts=[(X, LIB, "local-dev")], brief_edit=_two_workers)
claude, gh = d.FakeClaude(), FakeGitHub()
_tick(brief, mind, home, 0, claude, gh)
publish()
Expand Down Expand Up @@ -737,8 +747,8 @@ def test_add_is_refused_on_a_claim_on_mind_origin(tmp_path, monkeypatch):
def test_add_overrides_the_briefs_exclude_list(tmp_path, monkeypatch):
mind, brief, home, slot, publish = _add_shift(
tmp_path, monkeypatch, drafts=[(X, LIB, "local-dev")],
brief_edit=lambda s: s.replace(" - backlog: none\n",
f" - backlog: none\n - exclude:\n - {X}\n"))
brief_edit=lambda s: _two_workers(s).replace(
" - backlog: none\n", f" - backlog: none\n - exclude:\n - {X}\n"))
claude, gh = d.FakeClaude(), FakeGitHub()
_tick(brief, mind, home, 0, claude, gh)
publish()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_orchestrator_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ def test_one_unreadable_session_stops_blocking_after_its_reads_run_out(tmp_path)
"""Review item 2: after UNREADABLE_READS unreadable reads in a row a session
is `unmeasured` — it no longer refuses every spawn; its reservation counts
as its usage and the cap rule decides. The row says unmeasured, never 0."""
mind, brief, home = d._shift(tmp_path, names=("t1", "t2", "t3"), budget=800)
mind, brief, home = d._shift(tmp_path, names=("t1", "t2", "t3"), budget=800,
extra=" - max-workers: 2\n")
slot = orch.slot_dir(brief, home)
claude = d.FakeClaude()

Expand Down
13 changes: 12 additions & 1 deletion tests/test_orchestrator_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,23 @@ def test_stop_halts_a_running_shift_at_the_next_tick(tmp_path):
# --- (d) usage caps ---------------------------------------------------------------

def test_max_workers_refuses_the_next_spawn(tmp_path):
mind, brief, home = _shift(tmp_path, names=("t1", "t2", "t3"))
mind, brief, home = _shift(tmp_path, names=("t1", "t2", "t3"), caps=" - max-workers: 2\n")
r = orch.tick(brief, mind, home=home, now=NOW, spawner=orch.FakeSpawner(seconds=3))
assert len(r["spawned"]) == 2
assert r["refused"] == [{"task": "t3", "why": "max-workers 2 reached"}]


def test_a_brief_without_caps_gets_the_code_defaults_4_workers_8_sessions(tmp_path):
"""PyAutoBrain#656 Witness: a brief with no `max-workers:` spawns 4, and
the session cap it falls back to is 8."""
assert orch._brief.CAP_DEFAULTS == {"max-workers": 4, "max-sessions": 8}
mind, brief, home = _shift(tmp_path, names=("t1", "t2", "t3", "t4", "t5"))
assert "max-workers" not in brief.read_text() and "max-sessions" not in brief.read_text()
r = orch.tick(brief, mind, home=home, now=NOW, spawner=orch.FakeSpawner(seconds=3))
assert len(r["spawned"]) == 4
assert r["refused"] == [{"task": "t5", "why": "max-workers 4 reached"}]


def test_max_sessions_refuses_past_the_shift_total(tmp_path):
mind, brief, home = _shift(tmp_path, names=("t1", "t2"),
caps=" - max-workers: 5\n - max-sessions: 1\n")
Expand Down
Loading