Repository navigation
feat(mate): let the owner cap how many workers a Bot keeps open - #37381
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns. The limit is owned by the operator and is off by default, so nothing changes on upgrade. The check runs in the same step that makes the slot, it covers create, revive and fork, and the PR removes nothing. Notes
[DESIGN-REVIEWED] 5b78609 Description read[DESCRIPTION-READ] 3ed133511e7064dd4c67f526a8193b856b4149c0aaed0e8590b32a33c8395707 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The cap is opt-in (default 0) and has a cause behind it (#37361). It doesn't copy the work ledger's item cap, because that cap counts board items, not sessions. Two framing gaps remain. Notes
What this change shipsInventory (7 items) — 5 justifiedIntent: let a Bot's owner put a hard limit on how many workers the Bot keeps open at once. This is an ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 5b78609 Description read[DESCRIPTION-READ] 89102bf444a8bf327036cfddab5149d563ddaaee208bdc0de9c8b17bad9b5696 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks. The blind reader understood the "Workers at once" row and its picker, and said it would use them. Notes
[UX-REVIEWED] 5b78609 Description read[DESCRIPTION-READ] 51e0c940e9d970ee6feca0cad219e6704c212292884f7e24f8e184c393282b7b That sha256 names everything this verdict read: the PR description, plus the 5 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Review detailsNo findings. Notes:
[OPUS-REVIEWED] 5b78609 Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ human override acceptedHuman judgment by @buluoray overrides the GPT 6.1 finding for [GPT-OVERRIDE] 5b78609 This comment is updated in place on each push. The model was not re-run because an authorized human decision supersedes it. False positive or not applicable? A repository writer can comment: |
384b0aa to
cd48e00
Compare
|
span=18a6f75e1e3c
|
|
span=420fdb4ad597
|
cd48e00 to
1c363f5
Compare
|
span=935618037b85
|
|
span=420fdb4ad597
|
|
span=3c50665586b6
|
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 25% chance that this change introduces a defect, above the 12% limit for approving on its own. The PR adds an owner-set max_workers limit per Bot (0 means no limit), enforced on session_create, session_fork and session_revive. The check is synchronous and the new worker is counted at mint (create), at stamp after a recheck (fork) and in the revive's final check, so parallel creates cannot both pass. Workers a restart brought back are counted from their saved records, read off the loop. The default of 0 preserves today's behaviour. On trust: only the owner route PUT /api/agents writes the field, change cards cannot reach agents.* paths, and the relay teammate roster is an allowlist. Core enforcement tests are solid. The gaps are a stale non-goal bullet, the owning system spec not updated, no backend test for the PUT route's write and validation, and no test that a fork or revive under the limit succeeds. None of these is a concrete failing path, so the recommendation is to approve with notes. An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
1c363f5 to
d611b6f
Compare
|
span=f99e9f510116
|
d611b6f to
054aaac
Compare
|
span=652d198adb29
|
054aaac to
66afd4e
Compare
66afd4e to
698edac
Compare
dc9519a to
4f867c6
Compare
4f867c6 to
5b78609
Compare
|
span=f99e9f510116
|
|
/ai-review override gpt 5b78609 deferred #37538: agent: the fork post-bind recheck can count its own child when a parallel restart read counts it during the bind. The result is a loud 409 bot_worker_cap_reached that clears on retry, and the owner limit is never passed. Leaving the child out needs the child key in fork_slot recheck contract, so it is deferred to #37538 with the cap registry work. |
Human judgment recorded@buluoray recorded a deferred release (class
This decision applies only to this commit. A new push requires a new judgment. |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Thanks for this. The cap logic is well contained. One thing is missing before this can move forward.
website/src/pages/members/CrewProfileSettings.tsx:515: on this head, nobody has seen the new "Workers at once" row rendered. Both images in the PR body point at local file paths, which GitHub cannot load, so they show as removed. The diff commits the capture harness (website/capture/bot-worker-cap.htmland.tsx) but no rendered image. The result is that the Design and UX lanes both said they could not evaluate the row. A UI control would then merge with neither its layout nor its copy reviewed. Smallest fix: render the existing harness in dark and light. Include the open picker and a row with a limit set. Attach the images as GitHub uploads in the PR body, or commit them undertemp-screenshots/. Then re-run the Design and UX lanes on that head. No code change is needed for this item.
Optional:
- A worker can still start runs through
spawn_run/spawn_sub_agents. Those runs never land instate._slots, sobot_worker_cap.py:64does not count them. Consider adding this path to #37538. - The settings caption (
en.json:9182, plus zh-CN) says workers that "can run at the same time". But a finished worker that is still open also takes a seat, as the backend refusal text says. Wording about open sessions would match the behaviour. ## Not a goalsays onlysession_createis checked, but the diff also checks revive and fork. Please keep those checks. A maintainer can correct the bullet and themembers_roster.py:445comment.docs/system-specs/modules/session-control.mdcould also mention the new refusal next to the per-creator ceiling.
|
@KiroCrewCaptain the required item is done, with no code change and no new head (still
On the optional notes:
|
|
This adds a new concept, so it needs a design sign-off from a maintainer before it can merge. A maintainer will post the decision here. Earlier review, item 1 (no rendered view of the "Workers at once" row): fixed. The body now has dark and light uploads of the open picker and a row with a limit set, and the Design and UX reviews both passed on this head after the uploads. Review result on head 5b78609: no blocking defect found. The cap check runs before the slot is made on create, revive and fork, and the new worker is counted in the same step that makes it, so parallel creates cannot both pass. The default of 0 keeps current behaviour, and read errors do not turn into refusals. Only the owner route writes Optional:
|
Withdrawn: every item in this review is fixed or answered on the current head (see the follow-up comment). Other holds on this PR are listed there.
bolichen97
left a comment
There was a problem hiding this comment.
Approve. Read the whole diff on this head, including the tests, every locale and config-baseline.json.
- Default matches main:
max_workersis 0, meaning no limit, andworker_cap_refusalreturnsNonewhenever the cap is 0 or the record is not the Bot's own worker. The baseline only addsagents.*.max_workerswithdefaultValue: 0. So nothing is refused until the owner picks a number, which keeps the stricter path opt-in. - Only the owner route (
PUT /api/agents/<name>increw_update.py) writes it, validated as an int in 0..32 with bools rejected; no Bot tool writes it. - Fail-open is right: an unreadable config or execution record gives cap 0 or an uncounted slot, never a refusal or a raw error, and tests pin both for revive and fork.
- The seat is taken at mint (
note_new_worker) inside the same synchronous window as the check, so parallel creates cannot both pass; revive checks in_final_checkbefore publish, fork in_recheck. - No regex in product code.
Non-blocking: count_restored_workers runs a threaded record read on every own-worker create even when the cap is 0. It only reads slots not yet counted, so it is cheap after the first pass, but it could skip entirely when bot_max_workers is 0.
Not checked: no local run; I relied on the 106 green checks.
Problem / Motivation
Goal: A Bot's owner can set how many worker sessions the Bot keeps open at once, and the Bot cannot go past that number or raise it.
A Bot that plans "two or three workers" can open 16 at once today (#37361). Nothing writes the plan's number down as a limit. A Bot's chat is held only by the gateway-wide per-creator session cap (
session.max_per_creator, 50 by default), which is a fairness share between callers, not the owner's plan for one Bot.Why it matters
Every open worker spends credits and opens pull requests. In #37361 the owner could not stop the fan-out without stopping the Bot by hand. A limit the owner sets, with a default that stops a runaway, is the first of the per-goal limits that issue asks for.
Not a goal
concurrency_cap.session_createis checked.What changed (motivation → approach → change)
The plan's worker count binds nothing, so a Bot opened a worker per finding. Each Bot now has its own
max_workerssetting, set by the owner on the Bot's settings page in a new Workers at once row. It is 0 by default, which means no limit of the Bot's own, so nothing changes until the owner picks a number from 1 to 32. That keepsrfc-work-ledger-concurrency-cap.mdsection 7: the bound comes from the host's resources unless a person chooses one.With a limit set, every verb that would leave one more of the Bot's workers open is refused with
bot_worker_cap_reached(409):session_createfrom the Bot's chat or from one of its workers,session_reviveof an archived worker, andsession_forkof a worker. Each asks one check,worker_cap_refusal, with the execution record the new slot will run under, and counts the Bot's open workers across all its chats. A new worker is counted in the same step that makes its slot, so two parallel creates cannot both pass. A worker that a restart brought back is counted from its saved execution record, read off the event loop before the check. A worker keeps its seat until it is closed, and the refusal says so. A handoff opens no slot, so it is not checked. The cap counts the Bot's own worker sessions, on its worker template. A session that a worker opens on another template keeps the Bot's member id but is not counted; the per-creator cap still bounds it, and counting it is #37538. Only the owner routePUT /api/agents/<name>writes the field, and no Bot tool calls that route. The field is shipped onGET /api/membersfor the settings card and withheld fromGET /api/agents, like the other worker settings.Where: the field and its range in
src/kiro_crew/config/sections_session.py(read inconfig/loader_pipeline.py, re-exported byconfig/sections.py, listed inconfig-baseline.json); the owner write indashboard/agent_admin/crew_update.py; the read indashboard/handlers/members_roster.py; the count and refusal in the newdashboard/state_parts/bot_worker_cap.py, called fromdashboard/session_control_parts/session_create.py,session_revive.pyandsession_tree.py; the doc insrc/kiro_crew/docs/session-control.md; the row inwebsite/src/pages/members/CrewProfileSettings.tsx, the type inwebsite/src/api/client/agents.ts, and three strings in all 12website/src/i18n/locales/*.json(plus the regenerateden-XA.json).Backwards compatibility
Compatible: a record with no
max_workersloads as 0, no limit, so every Bot behaves as it does on main until its owner sets a number. A hand-edited value outside 0-32 is held in range.Removes nothing: the change adds a field and a refusal that only fires once an owner sets a limit; no field, route or key is removed or renamed.
Tests
test/test_bot_worker_cap.py: no limit by default (three creates pass); a hand-edited -1, 99 or a string is held in range; the create past a limit is refused withbot_worker_cap_reachedand creates nothing; a closed worker frees its seat; a worker whose in-memory count was dropped (as after a restart) still takes its seat; with the birth write's own registration switched off, the second create is still refused; a worker's own create, a fork of a worker and a revive of an archived worker are each refused past the limit. Mutation check: removing any one of the create, fork or revive checks, the restore read, or the count at mint turns at least one of these red.website/src/pages/members/CrewProfileSettings.test.tsx: the row reads "No limit" by default, the caption says only the owner changes it, a pick writes{ max_workers: 3 }as a number and touches no thread, "No limit" is sent as 0, and a stored value off the step list is offered checked.test/test_agents_roster_contract.py:max_workersis listed as withheld fromGET /api/agents.Manual verification
Component render with mocked data (
website/capture/bot-worker-cap.html, opened in a headless browser): the row reads the stored limit, the picker checks it, and the page logs no errors, in dark and light. Not run on a live gateway.Screenshots / video
Component render, not the live page (mocked data).
Light theme
Related Issues
Part of #37361
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)