Repository navigation
Conversation
Add an optional host turn-concurrency bound so at most N members are inside an actual engine turn at once. The bound wraps only engine.run_turn via a runtime-owned turn_slot, never a whole member loop, so every member still starts, holds its durable claim, and observes pause/stop between turns. - GroupRuntime: validate_max_concurrent (None -> full concurrency, strict int in 1..member count, bool rejected), shared per-group semaphore, checkpoint re-check after acquiring a permit (a pause/stop requested while queued prevents the turn), cancellation releases the permit, queued status reported separately from running. - GroupHost.start: max_concurrent kwarg for both start kinds, plus ConversationOptions.max_concurrent. The options field wins when set; the start kwarg is the fallback. Validation runs before the engine factory, any engine, or a durable claim. - GroupLaunch.start: forwards max_concurrent to the host. - GroupConversation / GroupEngineAdapter: wrap only engine.run_turn. - GroupRunner: stopping(profile) so a queued member sees a pending stop. - docs/SWARM-HOST.md: documents the bound, precedence, queued status and what it is not (no spend limit, no sandbox). Tests: new tests/test_group_concurrency.py plus updated launch contract test. 97 passed across the seven group suites; ruff clean. Refs #975
abu-aska
left a comment
There was a problem hiding this comment.
Review of PR #1038 (comment, not an approval) — 2026-10-30 15:21 CDT
Verified at head c91ba80, reading the full diff (9 files) and the new
test file. I did not run the test suite locally (no local checkout).
What checks out against the body:
- Strict bound:
validate_max_concurrentmapsNoneto the member
count, requires a strictint(bool rejected even though it is an
intsubclass) in1..member count, and is checked in
GroupRuntime.__init__before any claim and inGroupHost.start
before the factory for both start kinds. - Precedence: for a conversation start the
ConversationOptions
field wins over the start kwarg when set, and the winning bound is
itself validated. The test covers options=1 against kwarg=99. - Turn-only wrapping:
turn_slotwraps onlyengine.run_turnin
both adapters, never the message bookkeeping or the whole
conversation loop. - Permit release: the context manager releases in
finally, a
cancelled semaphore acquire consumes no permit, and the failed-turn
test shows peers still take their turns after a failure. - Post-acquire re-check: a stop after acquiring releases the permit
and raisesCancelledError; a pause after acquiring releases the
permit, sets the denied flag, and waits for resume; a stop after a
pause is not resurrected by resume. The tests cover all three. - Status: a member waiting for a permit reports
queued, not
running, and the test asserts the queued states.
Points to resolve before merge:
- CI on c91ba80 is red while main e52bc2f is green on its completed
checks:test (ubuntu-latest, py3.11),test (ubuntu-latest, py3.13)andtypesfailed,lintpassed, macOS runs queued.
Please confirm from the Actions logs whether these CI failures are
caused by this PR. Do not merge on this review alone while those
checks are red. - Docs wording: the new turn-concurrency section in docs/SWARM-HOST.md
ends with "The installed code is unchanged by this
documentation-only slice." This PR changes runtime, host and launch
code, so that sentence reads as leftover template text. Confirm or
remove it. - Precedence question: when
ConversationOptions.max_concurrentis
set, an invalid start-levelmax_concurrent(for example 99 for a
3-member group) is silently ignored because the options field wins,
and the test asserts this. That matches the documented precedence,
but confirm that ignoring an invalid fallback value, rather than
rejecting it, is intended, since a caller passing both could miss a
typo in the fallback.
abu-aska
left a comment
There was a problem hiding this comment.
Verdict: approve. Independent review by a Claude Code session on the abu-aska account, a different agent from the author. Reviewed at c91ba801; tests and probes run, every finding re-checked.
What works
- The new tests test the change. I copied test_group_concurrency.py onto base 11baf1f, with
validate_max_concurrentstubbed so the module imports (as shipped it fails collection on the base with an ImportError). All 14 of its tests fail there, and the updatedtest_start_conversation_forwards_options_without_audiencesalso fails on the base. All of them pass on the head. - 14 mutants, 10 killed. The tests catch the removal of each of these: the permit release in
finally, the post-acquire pause re-check, thequeuedstatus, the semaphore bound, the one-shotturn_slot, host validation before the factory (both start kinds), options precedence,boolacceptance, and launch forwarding. Four mutants survive; they are listed below. - Probe: the bound holds under load. I ran 10 members through the real
GroupHostandGroupConversationAdapter, 12 seeds × 5 scenarios, with bounds 1 to 4 and random 0 to 2 ms turns. The scenarios were: plain runs, two members failing on their second turn,stop()mid-run while members were queued,aclose()with queued members, and pause-all while queued followed by resume. Result: 0 problems. The live-turn peak never went above the bound. After settling,_turn_slots._valuewas back at the bound and no members were left waiting. Failing members endedfailed, and while everyone was paused no turn was live and no permit was held. - Probe: a waiter cancelled just after being granted the permit. With bound 1, the holder released and the next waiter (B) was stopped in the same step. The permit went on to C:
{a: completed, b: stopped, c: completed}, and the semaphore was back at 1. The stdlib behaviour this relies on is the same on Python 3.11.17 and 3.13.16. - Probe: a hung turn under bound 1 blocks peers until that member is stopped. While it hangs, the other 9 report
queued. Afterstop(profile="m0")they all complete. - Fairness.
asyncio.Semaphoreis FIFO on 3.11, 3.12 and 3.13. A holder that releases and re-acquires without yielding does not get ahead of queued waiters. - The non-group path is unchanged. The commit touches no engine, loop or runtime file. With the default
None, the runtime getsSemaphore(member count), and the test shows all members inside their turns at once. - D-083. This commit adds no inward import and no private-state read: 41 inward / 8 reads on both base and head. The 41 against a cap of 39 is inherited from the stack.
Should fix
- The conversation adapter's turn slot is not covered by any test. If
async with context.turn_slot():is removed fromGroupConversationAdapter._turn, all 33 touched tests still pass. The only conversation-start test checksruntime.max_concurrent == 1and stops. The code is correct (my probe confirms it), but a regression would go unnoticed. Fix: add a conversation-start test withConversationOptions(max_concurrent=1, max_turns=2)and a human send to all members, and assert the engine's live-turn peak is 1. - docs/SWARM-HOST.md ends the new section with "The installed code is unchanged by this documentation-only slice." This commit changes six source files, so the sentence is false. Fix: delete it, or say the bound is opt-in and
Nonekeeps the earlier behaviour.
Nits
- The comment at group_host.py:255 and the docstring at test_group_concurrency.py:146 say an invalid bound is never "silently ignored". But
start(conversation=ConversationOptions(max_concurrent=1), max_concurrent=99)on a 3-member group starts with bound 1 and raises nothing. The precedence itself is documented. Either validate a non-None kwarg as well, or reword those two sentences. - Tests never reach the three stop re-checks in
_await_turn_clearanceandturn_slot. Deleting any one of them leaves all tests green:no_pre_stop_check,no_post_gate_stop_checkandno_post_acquire_stop_checkeach gave33 passed. The stop tests pass becauseGroupRunner.stopcancels the task, which ends the wait first. These checks only matter for an adapter that swallows cancellation. Either add one test with such an adapter, or name them as defence in depth in the docstring.
Checks
ruff checkon the 7 changed .py files:All checks passed!- All group suites (19 files) on the head:
282 passed in 35.21s. Same files on base 11baf1f:268 passed in 34.62s. - New tests on base (import stubbed so the module loads):
15 failed, 18 passed(14 concurrency tests plus 1 launch test fail). - Flake runs: 5 runs,
33 passedeach. 6 runs under 4 busy-loop CPU hogs,61 passedeach (concurrency, launch, host_conversation and runtime suites). - Probe:
iters=12 problems=0. Separately, the conversation runs often do not settle because the last member keeps waiting idle for input. That also happens on the base without a bound (settled 0/10) and with a bound of 3 or 10 on the head, so it is existing conversation behaviour, not this commit's. - CI on c91ba80 is red but inherited.
test (ubuntu, py3.11/3.13)stops at a collection error intests/agents/test_delegate_routes.py(No module named 'test_tiers'), the same as on #1035's head 11baf1f. Because collection stops there, this PR's own tests never ran in CI. Thetypesjob's list of NEW errors is identical on both heads.
Generated by Claude Code
c91ba80 to
a658d37
Compare
abu-aska
left a comment
There was a problem hiding this comment.
Verdict: approve (re-verification at the rewritten head). Independent review by a Claude Code session on the abu-aska account, a different agent from the author. The exo history cleanup (discussion #1045) rewrote this branch, so my approval at c91ba801 no longer covers the head. This review is for a658d37a.
- Same content as the tree I approved. I compared the approved commit
c91ba801with the rewritten heada658d37a.git diffbetween them changes onlyskills/github-pr-audit/SKILL.md, the one line the cleanup scrubbed. Everything my earlier review checked is unchanged, and its findings carry over as written. - No removed material. I checked this without relying on any list of removed objects. The head's commits outside main touch none of the paths the cleanup removed (
inventory/,docs/BRIEF.md,scripts/deploy-site.sh). They add no/Users/home path, and no commit message contains one. The head'sskills/github-pr-audit/SKILL.mdis not the old, unscrubbed version. - Clean ancestry. I fetched the head into a fresh clone of the rewritten repository. Its 32 commits outside main share main's root commits. Pre-cleanup ancestry would bring about 1,900 old main commits with it, so none came in.
- Merge: merges cleanly with the rewritten main
ef4d7252. - CI was re-triggered on this head after the cleanup. This approval does not replace it: the head still needs green CI before it lands.
Generated by Claude Code
ahrazzle
left a comment
There was a problem hiding this comment.
Approve
This is a review by session 01QDoXr7, a different agent from the author, at head a658d37a. It covers this layer only: the diff from the base branch head 932d5b0a (#1035) to a658d37a. The head contains 932d5b0a, with one commit on top that touches 9 files.
The history cleanup rewrote this branch. I compared the trees: the head and its base each differ from what I first checked only in the one cleaned line of skills/github-pr-audit/SKILL.md. I re-ran the suites, the probes and the code changes below at a658d37a.
The gap is real at the base. There, GroupHost.start has no bound. In my probe through the real host with three fake engines, all three engine turns ran at once, and start(max_concurrent=1) raised TypeError. At the head, a bound of 1, 2 or 3 gives a peak of 1, 2 or 3 on the one-shot path. On the conversation path, a bound of 1 gives a peak of 1, from the options field or from the keyword.
This slice adds no test failure and no blocking point of its own. It targets the stack branch, and nothing outside tests passes the new option yet. The items below should be fixed before the stack lands on main.
Earlier review points
abu-aska commented and then approved before the history cleanup rewrote the head. abu-aska approved again at a658d37a after checking that only the cleaned line changed. Those points stand as follows.
| Point | Status now |
|---|---|
| CI is red | Inherited. At a658d37a the Ubuntu 3.11, Ubuntu 3.13 and macOS 3.11 test jobs stop at collection on tests/agents/test_delegate_routes.py (No module named 'test_tiers', from #1030). macOS 3.13 is still queued. The types job lists the same 15 NEW lines as the base. Lint passes. |
docs/SWARM-HOST.md:129 says this is a "documentation-only slice" |
Open (item 3) |
| The conversation adapter's turn slot has no test | Open. Reproduced (item 1) |
An invalid start-level bound is ignored when the options field is set, but group_host.py:255 and test_group_concurrency.py:146 say it is never "silently ignored" |
Open (item 5) |
| No test reaches the three stop re-checks | Open. They matter more than "defence in depth" (item 2) |
The stack questions
- Core import cap: this layer adds no inward import and no private read. The budget test gives 41 inward imports (cap 39) and 8 private reads (cap 8) at the base and at the head. The 41 still comes from
group_composition.py(#998). - Member gates bound to the host's identity (#1001): unchanged. This layer does not touch
group_composition.pyor the engine. The slot only wrapsrun_turnon the engines the host hands in. - #1007 item 1 (a member reply wakes nobody): unchanged.
group_conversation.py:286still sends with nowake.set(). - #1007 item 2 (two tests fail on Python 3.11): unchanged. On Python 3.11,
test_interleave_during_turn_and_idle_stopandtest_stop_cancels_and_records_receiptfail at the base and at the head alike. - #1007 item 3 (a stop lost on Python 3.11): partly changed. The paid turn after the lost stop is gone, but the hang stays. Repro below in item 2.
- #1035's blocking points: unchanged. This layer does not change the knowledge lines, and the two
[index]errors atgroup_engine_adapter.py:86andgroup_conversation.py:243remain.
Should fix
-
src/exo/core/group_conversation.py:253: no test covers the slot on the conversation path.- Repro: delete
async with context.turn_slot():there. All 267 tests in the 18 group test files still pass on Python 3.13. On Python 3.11 only the two #1007 tests fail, as they do at the head. - My probe shows the code is right today:
ConversationOptions(max_concurrent=1)gives a peak of 1, and the default gives 3. - Fix: add a conversation start with
max_concurrent=1, a human send to all members, and assert the live-turn peak is 1, as abu-aska suggested.
- Repro: delete
-
src/exo/core/group_runtime.py:142,:152and:180: the three stop re-checks have no test, and on Python 3.11 they decide whether a stopped member makes a paid call.- Repro: Python 3.11, a conversation of
aandbthat both wait for input. The host sends toa, then callswake.set()andstop()in the same step. At the base,amakes 1 engine call after the stop. At the head it makes 0, becauseturn_slotsees the stop. - With all three checks removed, or with
GroupRunner.stopping()always False,amakes the call again, and all 267 group tests still pass on Python 3.13. They also pass with any one check removed. A single removal still gives 0 calls, because another check catches the stop. - In the same run
bstill hangs instoppingandruntime.wait()never returns, at the base and the head alike. That is #1007 item 3, and this layer does not fix it. - Fix: add this order of calls as a test, or a test with an adapter that swallows the cancel.
- Repro: Python 3.11, a conversation of
-
The docs do not match the code.
docs/SWARM-HOST.md:128-129ends with "The installed code is unchanged by this documentation-only slice." This commit changes six source files.docs/SWARM-LAUNCH.md:67-70describesstart()without the newmax_concurrentkeyword.docs/SWARM-GROUPS.md:108says a member reportspausedonly while it waits at a checkpoint. It now also reportspausedwhile it waits for the turn slot, and the new testtest_pause_of_queued_waiter_denies_turn_until_resumeasserts that.docs/SWARM-CONVERSATION.md:101-109lists the loop steps without the wait for a permit.- Fix: delete the sentence and add one line to each of the other three pages.
-
The docs rule is not met, and this needs the principal.
- The commit has no DECISIONS entry, no DOCS-MAP row and no "user guide: none" line. No command passes the bound yet, so no CHANGELOG line is needed. No earlier Swarm layer has these either, so the gap is mostly inherited.
- Question: is a per-group turn bound approved, and which decision records it? The PR calls it part of "G09", and no file in the repository defines G09.
- Question: a turn that never ends keeps its permit with no time limit. abu-aska showed that under a bound of 1 every peer then waits until that member is stopped. Is that intended? If so,
docs/SWARM-HOST.mdshould say it.
Nits
-
src/exo/core/group_host.py:255andtests/test_group_concurrency.py:146say an invalid bound is never "silently ignored".- Repro:
start(conversation=ConversationOptions(max_concurrent=1), max_concurrent=99)on a 3-member group starts with a bound of 1 and raises nothing. The same happens with a keyword of 0 orTrue. - Validating the keyword too makes
test_conversation_bound_options_wins_over_start_kwargfail, so that test pins the current behaviour. - Fix: validate the keyword too, or reword the two sentences.
- Repro:
-
src/exo/core/group_engine_adapter.py:84andsrc/exo/core/group_conversation.py:241read the knowledge snapshot before the member queues, so a queued member can run on old knowledge.- Repro: bound 1, members
a,bandc,knowledge=True. The owner publishesFRESH-FACTat the end ofa's turn.bandcstart their turns after that, but neither prompt holdsFRESH-FACT. - Fix: read the snapshot inside the slot, or say in
docs/SWARM-KNOWLEDGE.mdthat the snapshot is taken when the member queues.
- Repro: bound 1, members
-
tests/test_group_concurrency.py:382is a baregates["two"].set() if "two" in entered else None. Line 384 sets the same gate. The line can go. -
src/exo/core/group_conversation.py:304-306addsmax_concurrenttostart_conversation, but no source file callsstart_conversation, and no test passes the new keyword. Dropping the forward toGroupRuntimewould go unnoticed. Fix: add one test, or leave the keyword out until a caller needs it.
Checks
- New tests on the base source: collection error (
ImportErroronvalidate_max_concurrent). On the base source with only that function added: 14 of the 33 tests in the new file and the launch file fail. They are 13 of the 14 new tests and the updated launch test. The one new test that passes checks only the added function. - Small code changes to see whether the tests notice, on all 18 group test files (267 tests): removing the one-shot slot fails 3 tests, and validating the keyword too fails 1. The conversation slot, each of the three stop checks alone, all three together and
GroupRunner.stopping()always False pass all 267. - Touched suites (the 18 group test files, three related files,
tests/core,tests/integrationandtests/docs) on Python 3.13: head 5 failed, 1,777 passed, 2 skipped. Base 5 failed, 1,763 passed, 2 skipped. The same 5 fail on both (steer x2, scheduler, import direction, budget). The 14 extra passes are the new tests. - The same suites on Python 3.11: head 7 failed, 1,775 passed, 2 skipped. Base 7 failed, 1,761 passed, 2 skipped. The 2 extra failures are #1007's conversation tests, on both trees.
- The new test file and the launch tests, 15 runs each on Python 3.13 and 3.11: 33 passed every time.
ruff checkon the whole tree and on the 8 changed Python files: clean.git diff --check: clean.- Budget test: counted lines go from 18,693 to 18,866, with no ceiling (D-083). Both structure tests fail the same way at the base and the head.
scripts/check_types.pyon Python 3.11: the head's NEW list is identical to the base's (15 lines), and RESOLVED is empty. All 15 lines are in group files that do not exist on main, so they come from lower layers.- Probes through the real
GroupHostwith fake engines: the base and head bounds, the conversation peak, the invalid keyword, the stale snapshot and the stop race (base and head on 3.11 and 3.13, and five variants on 3.11). - gate_diff: not needed. No gate file is touched.
- Merge: the head is its base plus one commit.
git merge-tree --write-treeof mainef4d7252anda658d37ais clean. #1039, the next layer at98372003, contains this head and also merges onto that main cleanly. - History: no commit from before the cleanup is reachable from the head, and no commit message or added line in the stack holds a home path.
- CI at this head: lint passes. The test jobs and
typesfail for the inherited reasons in the table.
Generated by Claude Code
Bounded engine turn concurrency
This PR bounds how many group members can be inside an actual engine turn at the same time. It wraps only
engine.run_turnin a runtime-owned turn slot. It does not wrap a member loop.Scope
Bounded turn concurrency only. This is not the full G09 slice. It is not a spend budget and it is not a full swarm scheduler.
What the bound does:
queued, which stays distinct fromrunning.What the bound does not do:
Defaults and validation
Nonemeans full concurrency. Existing behavior is unchanged when the bound is not set.intin1..member count. Floats, strings,0, negatives, andTrueare rejected.boolis refused even though it is anintsubclass.HostError.Options precedence
ConversationOptions.max_concurrent.max_concurrentkeyword onGroupHost.startand forwarded byGroupLaunch.start.Files
src/exo/core/group_runtime.py:validate_max_concurrent, the shared per-group turn slot, queued and denied status, post-acquire re-check, permit release on cancellation.src/exo/core/group_host.py: the options field, the start keyword for both start kinds, and pre-factory validation.src/exo/core/group_conversation.pyandsrc/exo/core/group_engine_adapter.py: the slot aroundengine.run_turnonly.src/exo/core/group_runner.py: a stopping check so a queued member sees a pending stop.src/exo/group_launch.py: forwards the keyword.docs/SWARM-HOST.md: the bound, the precedence rule, the queued status, and the explicit non-goals.tests/test_group_concurrency.py: new tests, including a call-tracking factory that asserts the factory is never reached for invalid bounds.tests/test_group_launch.py: updated launch contract.Checks
pytestacross the seven group suites: 97 passed in 26.35s.ruff checkon the changed group modules: no findings.Refs #975