Skip to content

fix(subagent): backport the macOS memory-pressure hold to 0.8 - #16567

Merged
bolichen97 merged 1 commit into
release/0.8.0from
backport/0.8.0-macos-pressure-hold
Oct 3, 2026
Merged

bolichen97 merged 1 commit into
release/0.8.0from
backport/0.8.0-macos-pressure-hold

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: (release/0.8.0 backport of #15876) on 0.8, a root subagent start on macOS waits while the kernel reports memory pressure and one of this gateway's own dedicated runtimes is running, so the next 0.8 tag ships the 2 GiB floor together with its macOS backstop.

#16315 (R1) already gave release/0.8.0 the 2 GiB spawn floor. On macOS that floor reads only the Mach reclaimable page count, which does not show the compressor. A Mac can report gigabytes "reclaimable" while the kernel already rates its memory pressure as WARN, and the gate then admits another kiro-cli runtime into that state. #16315's own release-gating note says the tag that releases the floor must also carry this veto.

Why it matters

0.8 is the line users install, and a 16 GB Mac is the common laptop case. Without the veto, the lower floor admits starts into compressor pressure and swap thrash, and the whole machine slows, not just Kiro Crew. With this PR merged, the next 0.8 tag carries both the floor and the veto, as main's RFC (rfc-overload-resilience Q10) records them: one floor rule.

Not a goal

What changed (motivation → approach → change)

This PR implements mainline-plan unit R2 / G3-080 (g3-backport). It is one commit, a cherry-pick -x of #15876's squash 44ea05c0ed (which already holds both of #15876's commits) onto release/0.8.0. The commit keeps #15876's message verbatim, with a lead paragraph on the 0.8 tag and a "Backport to release/0.8.0" list of the adaptations.

What the hold does is unchanged from main; the full statement is docs/system-specs/modules/subagent.md (macOS: the kernel memory-pressure hold):

  • platform_compat.memory_pressure_level() reads kern.memorystatus_vm_pressure_level (None off macOS or on failure, which fails open).
  • At WARN or worse, a ROOT start waits in the window as memory_pressure while a dedicated runtime of ours runs. Nested children and claim re-entries are never held, and the hold is off with the floor (0).
  • Bounded at 1800 s per row; a row past it ends "never started: waiting for memory".
  • The level is reported in resource_status, [RESOURCES] and diagnostics. The eager-spawn path takes no pre-warm while the hold applies.
  • The run card gets the never-started and ran-of-total headers and a counted ErrorNotice, in all 12 catalogs.
  • Commit 2 of fix(subagent): veto macOS starts under kernel memory pressure #15876 (also in the squash): a refill keeps an App Kit row's approval_mode, a defer-store outage answers still-queued instead of refused, and the channel spawn reply reports refusals.

Most files took #15876's patch byte for byte. Twelve conflicted, and each was resolved against 0.8's code:

  • subagent_wait_reasons.py: adds the memory-pressure constants only. 0.8 has no QUEUED_KIND_TEXT, so that entry is left out.
  • subagent.py: the manager gains only the _pressure_* fields and _held_approval_modes. _pressure_recheck_handle joins the intentional-cancel timer set. The _PRESSURE_HOLD_MAX_WAIT_SECS comment says release/0.8.0 has no agent.subagent_queue_max_wait_secs.
  • subagent_manager/cancellation.py: shutdown cancels only the pressure re-check timer, because 0.8 has no depth retries.
  • subagent_manager/admission/pump.py: the TYPE_CHECKING block gets only the entry_is_child stub.
  • subagent_manager/run.py, mcp_tools/spawn.py: only the imports 0.8 needs.
  • context.py: the [RESOURCES] comment lands here, because 0.8 has no context_assembly/turn.py.
  • test/conftest.py: only the _no_live_kernel_memory_pressure pin.
  • test/test_admission_gate.py: main's one-line autouse requests conftest's close_subagent_managers, which 0.8 lacks. The module therefore carries its own _close_subagent_managers autouse, the same body 8 test files on 0.8 already use (test_subagent_sizing.py and others). Every manager is closed at teardown.
  • Specs: subagent.md keeps 0.8's subagent_queued paragraph and adds the memory-pressure no-figures note. injected-messages.md keeps 0.8's producer paths and adds the [RESOURCES] row. learn-cron-dashboard.md adds the pre-warm hold sentence to 0.8's ws.py text.

Spec updates in this PR: docs/system-specs/modules/subagent.md, docs/system-specs/common/injected-messages.md, docs/system-specs/common/platform-compat.md, docs/system-specs/modules/learn-cron-dashboard.md, docs/system-specs/modules/taskq.md, docs/architecture/context-management.md. User docs: src/kiro_crew/docs/subagents.md, configuration.md, dynamic-subagent-sizing.md.

Backwards compatibility

Compatible. Nothing 0.8 accepts today is rejected or renamed, same as #15876 on main:

  • Off macOS, and with spawn_min_memory_gb = 0, every new branch is inert.
  • Older dashboards fall back to the default queued text for the additive memory_pressure reason.
  • A caller naming an unknown agent is refused agent_not_found before any memory or capacity wait instead of after it.
  • A refused channel spawn reply changes from "Spawned ..." to "not started: ".
  • An App Kit spawn that waited keeps approval_mode="auto" on refill instead of raising a prompt.

Tests

All tests come from #15876 and run on this branch against 0.8 source. Run against base source with base conftest, the cherry-picked test files give 75 failed and 8 errors.

  • test/test_admission_gate.py (96 tests): the hold queues in the window with no store defer, the five pass-through cases, posture-critical wins, the per-row and episode bounds, slot-release and timer re-checks, approval release per entry, the real readers end to end, _owns_dedicated_runtime[*], and the defer-outage path. It also checks that the user docs state the bounds the code uses. 58 of these fail on 0.8 source.
  • test/test_platform_compat.py::TestMemoryPressureLevel: each level through a real ctypes pointer, plus failure shapes. On base it fails at collection.
  • test/test_resource_status.py: the level read, summary lines, [RESOURCES] and the held flag (13 fail on base).
  • test/test_spawn_floor_defaults.py: the top-up waits on the hold for a root, never for a nested child (2 fail on base).
  • test/test_eager_spawn.py, test/test_messaging_commands.py: no pre-warm under the hold, and the refusal reply.
  • Frontend: SubagentRunCard.test.tsx, ActivityViewer.test.tsx, and the i18n gate, strict-rule, plural and all-languages tests.

Local results:

  • 109 targeted backend files, run on facd28b5a0: 5735 passed, 32 skipped. They cover every touched test file, every test_subagent*, test_spawn*, test_taskq*, mcp_core, chat_runner, fairness, resource and config-baseline, plus the test files the new base commits touched.
  • test_admission_gate.py serial with a descriptor probe: fds 12→12 and threads 1→1 at session end (without the module autouse: 12→54 and 6 live taskq-writer threads).
  • Frontend: 12 vitest files with 301 passing, tsc and eslint on the touched files, i18n:check against origin/release/0.8.0 (PASS) and lint:i18n. The three rebases since then brought in backend-only commits.
  • After the last rebase, onto 6997221a88 (fix(memory): leave over-budget guides out instead of refusing the turn (release/0.8.0) #16556 also edits context.py), the overlapping set gave 1300 passed and 28 skipped: admission gate, resource status, context management, essential context, eager spawn, messaging, spawn floor and platform compat.
  • Static gates: black ratchet, subprocess-encoding, isort and flake8 on the touched files, mypy src/kiro_crew (no issues in 1864 files), docs-lint.sh, and the harness-parity gate against release/0.8.0.
  • local-gate.py --base origin/release/0.8.0 planned effectively the full suite (2833 backend files), so it was not run. CI runs the suite.

Manual verification

N/A: unit coverage is sufficient for a backport. The behaviour is identical to main, where #15876 merged with its macOS-only test reading the real sysctl on the macOS CI runners. As on main, no real Mac was available here. The XNU source verification of the sysctl values is in #15876's description.

Screenshots / video

The frontend patch (SubagentRunCard, subagentQueuedReason.ts, backendPhrases.json, all 12 locales) applied byte for byte from #15876, so the rendered surfaces are the ones captured there from the real built SPA at #15876's head.

Held, run card (dark):

Run card: 3 agents queued, the starts resume on their own once it eases or the running agents finish; starts give up once the pressure has lasted 30 minutes (dark)

Every member ended at the bound, run card (dark):

Run card: 3 agents never started; 3 never started, macOS memory pressure did not ease in time; once it eases or a running agent finishes, use Retry failed in the Subagents panel (dark)

Mixed wave, run card (dark):

Run card: 2 of 3 agents ran, 2 done and 1 failed; 1 never started, macOS memory pressure did not ease in time, Activity Monitor shows it (dark)

Light theme and the Subagents panel

Run card: the same held wave on the light theme

Run card: 3 agents never started (light)

Subagents panel: Error, never started: waiting for memory (macOS memory pressure did not ease in time); retry once it eases or a running agent finishes

Related Issues

Part of #16480. Main: #15876. Refs #15244 #15890 #16315.

Depends on: nothing to merge. #16315 (R1, the 2 GiB floor) is already on release/0.8.0. Release dependency: the next 0.8 tag should carry this together with #16315.

If R3 (#16388, the queue-depth state) lands after this, its conflict is to add its depth-retry handles next to _pressure_recheck_handle, in the intentional-cancel set and at shutdown.

Pattern harvest

Not generalizable: this is a backport. The pattern harvest for the defect (an OS memory signal must back up a measured figure, never replace it) was done in #15876.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Backport of #15876 to release/0.8.0. #16315 already gave this branch the
2 GiB spawn floor; the critique of that change was that a 2 GiB floor on
a 16 GB Mac admits into compressor pressure unless the kernel's own
pressure verdict can veto it. With this change the next 0.8 tag carries
both the floor and the veto.

* fix(subagent): veto macOS starts under kernel memory pressure

On macOS the memory floor now has a second input: the kernel's
kern.memorystatus_vm_pressure_level. At WARN or worse a root start waits
while a dedicated runtime of this gateway is running, even when the Mach
reclaimable figure clears the floor. The level is the kernel's lagging
verdict (it has read NORMAL with 4.9 GB compressed and 4.8/6.0 GB of
swap in use), so it backs the figure up; it does not replace it.

- platform_compat.memory_pressure_level() reads the sysctl through
  sysctlbyname on the cached libc handle, now built once under a lock.
  None off macOS and on any failure, and None fails open.
- The gate reads the level fresh (resource_status
  .read_memory_pressure_level). The hold is off with the floor (0),
  never applies to a nested child or a claim re-entry, and only counts
  dedicated-priced runtimes of ours, so a shared wave never holds
  itself. A start priced shared is held too: it still launches the
  agent's MCP servers.
- It is a capacity-style wait, not a store deferral: the row stays in
  the window as memory_pressure (restricted rows too), the pump pick
  passes over held roots, every slot release and a 15 s timer re-check
  it. Past 1800 s a row is ended, never started ("never started: waiting
  for memory"), and an episode that outlives that bound ends new starts
  at once until it eases. The same rule is re-checked at approval
  release (per entry, so a held root never blocks a child) and at the
  shared-to-dedicated top-up.
- A critical posture wins over the hold, and agent validation now runs
  before the memory gates, so an unknown agent is refused at once; the
  event-loop callers run its directory scan off the loop.
- An unreadable Mach figure is reported on macOS as on Linux
  (memory_check_unavailable). The level is shown in resource_status,
  the [RESOURCES] line and the diagnostics bundle; the eager-spawn
  admission takes no pre-warm while the hold applies.

* fix(subagent): keep a waiting row's approval and answer refusals

Three defects on the paths a held or deferred start now takes
routinely. Each predates the pressure hold.

- A window refill rebuilds an entry from the store, which never carries
  approval_mode, so a held or deferred App Kit spawn (approval_mode
  "auto") drained into a spawn prompt nobody can answer. The accepting
  process now keeps that row's mode in _held_approval_modes and the
  refill restores it; a restart still replays the row without it.
- finish_parked_defer announced a refusal on TaskStoreUnavailable while
  the row stayed QUEUED and due, so one id could get a refusal and a
  later completion. It now answers still-queued and re-pumps.
- The channel spawn reply said "Spawned" for a refused terminal record.
  It now says the subagent was not started, and why.

Backport to release/0.8.0. The hold, its tests and its UI land as on
main; only the code around them differs, and none of #16191, #16012 or
#15900 comes along:

- The 30-minute bound stays the named constant
  _PRESSURE_HOLD_MAX_WAIT_SECS, because the
  agent.subagent_queue_max_wait_secs key does not exist on 0.8.
- subagent_wait_reasons has no QUEUED_KIND_TEXT or queued_wait_text on
  0.8, so the new kind adds its constants only.
- The manager gains only the pressure-hold and approval-mode fields; the
  queue-depth emit and retry state, _admitting_waiting and
  _dispatching_ids stay main-only, and shutdown cancels only the
  pressure re-check timer.
- The [RESOURCES] comment is in context.py (0.8 has no
  context_assembly/turn.py). The spec keeps 0.8's subagent_queued
  paragraph and producer paths and adds the pressure rows to them.
- conftest gains only the kernel-pressure pin. 0.8's conftest has no
  close_subagent_managers fixture, so test_admission_gate carries the
  module-local autouse copy that test_subagent_sizing and seven other
  0.8 test files already use, and every manager it builds is closed at
  teardown, not at GC.

(cherry picked from commit 44ea05c)
@bolichen97
bolichen97 requested a review from a team as a code owner October 3, 2026 17:18
@bolichen97
bolichen97 requested review from kyleseaman and removed request for a team October 3, 2026 17:18
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of 0ec1373297adcaa0079ab4992455c85c80923712 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify the auto-triggered macos-on-demand lane ran green on this head before cutting the 0.8 tag — it is the only real-sysctl check standing in for the unavailable Mac.

[DESIGN-REVIEWED] 0ec1373

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

UX-level review of 0ec1373297adcaa0079ab4992455c85c80923712 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

Terminal error opens with "waiting for memory" after the hold has permanently given up — the reader couldn't tell whether starts would still happen.

Watch

  • MEMORY_PRESSURE_NEVER_STARTED ("never started: waiting for memory (…)") puts "waiting" inside a terminal, given-up state; the blind reader: "'waiting' … after it has already given up … blurs whether something is still going to happen." A macOS user who believes it's still waiting never clicks Retry and the work silently stalls — common 16 GB-Mac case, every timeout. Fix: open the panel row with the outcome, not the wait — e.g. "never started: memory pressure did not ease within 30 minutes; retry once it eases…" (the prefix is pinned in backendPhrases.json + the Python constant, both in this PR's surface).
  • Light theme (shot-04): the new two-line yellow queued text on the pale purple card is "noticeably hard to read" per the blind reader — pre-existing warning token, but this is the longest string yet rendered in it; worth a contrast check before tag.
  • Shot-06 composition: the card says "3 never started" while the panel's pre-existing "Dismiss done (3)" counts those same failures as "done"; the reader "wouldn't click until I understood whether dismissing loses information." Panel button is outside this PR — flag for follow-up, not this backport.

[UX-REVIEWED] 0ec1373

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🟡 CONCERNS

Premise-level review of 0ec1373297adcaa0079ab4992455c85c80923712 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: CONCERNS

Cited decision Q10 of rfc-overload-resilience is main-only; the 0.8 base RFC's decisions end at Q7, so the macOS hold rests on a generic "pressure defers" clause.

Not justified as shipped

  • Item 1 — inherited: the description grounds the hold's shape in "main's RFC (rfc-overload-resilience Q10)", but the base branch's copy records decisions Q1–Q7 only (no macOS hold, no 1800 s bound); on this base the shape is covered only by §3.4's generic "pressure defers, it no longer refuses" and §12's "memory pressure defers instead of refusing", a coverage call a human should ratify.
    Clears when: release/0.8.0's base carries the RFC revision recording the macOS hold (push or rebase once it merges), or a maintainer records /ai-review override first-principles 0ec1373297adcaa0079ab4992455c85c80923712: <decision>.
  • Item 6 — rides along: commit 2 of the cherry-picked squash, declared; harm (30-minute wait to learn a bad name) stands on 0.8 alone.
  • Item 7 — rides along: declared; the floor already queues App Kit spawns on 0.8, so the spurious re-prompt exists there today.
  • Item 8 — rides along: declared; a store outage refusing a row the pump then starts is a live 0.8 defect.
  • Item 9 — rides along: declared; "Spawned…" for a refused channel spawn misreports on 0.8 today.

What this change ships

Inventory (10 items) — 5 justified

Intent: FIX — backport merged #15876 so 0.8's 2 GiB spawn floor stops admitting kiro-cli starts into macOS compressor pressure; tests fail 75+8 on base.

  1. macOS root subagent starts wait while the kernel reports WARN+ pressure and a gateway runtime runs (off with floor 0) — inherited: base RFC ends at Q7; cited Q10 is main-only
  2. A held row past 1800 s ends "never started: waiting for memory" — justified
  3. Pressure level reported in resource_status, [RESOURCES] and diagnostics — justified
  4. Eager pre-warm skipped while the hold applies — justified
  5. Run card gains never-started / ran-of-total headers and counted errors, 12 locales — justified
  6. Unknown agent name refused agent_not_found before any wait, not after — rides along
  7. Queued App Kit spawn keeps approval_mode="auto" on refill, no prompt — rides along
  8. Defer-store outage answers "still queued" instead of refusing — rides along
  9. Channel spawn reply reports refusals as "not started: " — rides along
  10. Config help text and six specs state the hold in the same commit — justified

[FIRST-PRINCIPLES-REVIEWED] 0ec1373

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — 🔴 changes requested (blocking)

GPT 5.6 found at least one blocking issue that must be resolved before merging 0ec1373297adcaa0079ab4992455c85c80923712. Adjudication upheld 1 of 1 blocking finding(s); those must be resolved before merging.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/subagent_manager/admission/gate.py:709 -- Per-row side tables bypass the bounded dispatch window (origin: validation)
self._manager._held_approval_modes[agent_id] = approval_mode; since = mgr._pressure_holds.setdefault(agent_id, now)
Repeated App Kit spawns while pressure holds and all slots are occupied -> each durable row remains in these maps while the pump cannot expire it -> gateway memory grows with the disk backlog until OOM.
Anchor: a-bound-bounds-every-field-it-retains
Fix: Enforce one named pending-start cap before persistence, shared by all three pressure/approval collections, and count/report rejected overflow.
[GPT-REVIEWED] 0ec1373
[BLOCK-MERGE] 0ec1373

Adjudication (Opus 5) — is blocking on each finding proportionate?

HARM: HIGH — process-local growth proportional to the durable backlog, recoverable only by restart (the maps are rebuilt empty, gate.py:708, docs/system-specs/modules/taskq.md:100), and silent while it accumulates.

Conditions confirmed in this run: both maps are retained per row before the window decision — _held_approval_modes[agent_id] at gate.py:709 for every _durable and approval_mode spawn, and _pressure_holds.setdefault at gate.py:1628 reached from gate.py:1115 for every root admission while the level holds; the window retention at gate.py:1179-1188 is bounded but the maps are not keyed to it, so a row waiting on disk still holds entries. Release is only _forget_pending_start (subagent.py:5380-5384) at registration (gate.py:1383), rejection (gate.py:1876) or pump retirement (pump.py:1091,1112,1122); the one count-independent sweep, gate.py:1574-1577, prunes only when the level reads None and only past _PRESSURE_HOLD_PRUNE_SECS (7200 s, subagent.py:1047), and no accept-side cap on queued rows exists in taskq_accept (taskq_bridge.py:262).

REMEDY COST: real and non-trivial — a named pending-start cap must sit before taskq_accept, which adds a new refusal outcome to the durable admission path on a release branch, and a naive per-map bound is worse than none (dropping a _held_approval_modes entry re-raises the prompt gate.py:703-708 exists to suppress). That weighing does not decide this one: the finding is anchored to a-bound-bounds-every-field-it-retains, AUTOSDE.yaml:971 with blocking: true at :972, whose "one NAMED constant shared by every structure bounding the same population" and "overflow is COUNTED" clauses are exactly what the fix names — the rule's flag outranks my weighing.

[ADJUDICATION] 0ec1373 total=1 uphold=1 downgrade=0
UPHOLD F1 src/kiro_crew/subagent_manager/admission/gate.py:709 reason=autosde-blocking-rule
[GPT-ADJUDICATED] 0ec1373

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 0ec1373297adcaa0079ab4992455c85c80923712: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 0ec1373297adcaa0079ab4992455c85c80923712 — this comment is updated in place on each push.

Review details

No findings that block.

FINDING — src/kiro_crew/resource_status.py:96 — PRESSURE_QUEUE_NOTE ("new subagents may queue until it eases or this gateway's dedicated subagents finish") rides the [RESOURCES] line, resource_status and summary_lines off memory_pressure_held alone, but the gate's hold needs floor_gb > 0 (gate.py:1533), so on a macOS host at WARN with agent.spawn_min_memory_gb = 0 — whose help in this same diff reads "0 disables the check, that wait included" — the agent's context asserts a queue that can never happen and it downsizes waves for it → Fix: probe() already holds cfg; carry agent.spawn_min_memory_gb onto ResourceStatus and drop the queue clause from _pressure_clause()/summary_lines() when it is 0, leaving the MEMORY_PRESSURE_PHRASE half (which is what was measured).

[OPUS-REVIEWED] 0ec1373

Verdict parsed from the review's SHA-scoped output markers for commit 0ec1373297adcaa0079ab4992455c85c80923712.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 0ec1373297adcaa0079ab4992455c85c80923712: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 3, 2026
@bolichen97
bolichen97 merged commit 2ed4661 into release/0.8.0 Oct 3, 2026
20 of 22 checks passed
@bolichen97
bolichen97 deleted the backport/0.8.0-macos-pressure-hold branch October 3, 2026 20:43
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 3, 2026
bolichen97 added a commit that referenced this pull request Oct 4, 2026
Four main fixes for what users on 0.8 hit with parallel subagents:

- #14878: a wave's "N waiting to start" count ends at "1 waiting" under
  a finished turn, because a popped but unclaimed row was counted once
  more than the window holds. A popped row is now marked dispatching
  and left out of the count, so the last pop publishes 0.
- #16191: the count is re-published after every terminal, Stop all and
  stage Cancel, coalesced per parent; a failed store read publishes
  nothing instead of a false 0; a resident resume entry and a deferred
  spawn_async row are counted correctly; the pump's idle wake no longer
  spins (carries Matt Cohen's #15376 commit).
- #15022: a subagent inside the wait tool is not reaped as stalled
  before its declared duration.
- #16012: a spawn the memory gate deferred exists only as a task-store
  row, so spawn_status answered 404, spawn_list left it out and
  spawn_sub_agents reported it as an error, which made the model
  dispatch the work again. These ids now answer as queued, and the
  sub-agent synthesis waits while a sibling is still queued.

Backport to release/0.8.0. #14878 and #15022 apply cleanly. #16012 is
applied before #16191, its order on main, because #16191 was built on
it. #16012's conflicts are resolved against 0.8 code:
- api_spawn_list has no persisted half and no per-row audit on 0.8, so
  the queued half is listed beside the live half only.
- The persistence fallback of GET /api/spawn/{id} keeps 0.8's shape (a
  run folder reads done); the "no recorded ending is not done" change
  needs main's ending classifier and is left out.
- The Slack gateway and chat runner keep 0.8's orchestrator mode, so
  the synthesis arm stays chat-mode only.
The tests that read main-only APIs are adapted to those shapes, and
test/conftest.py gains main's close_subagent_managers fixture, which
the new tests request. The subagent spec drops the sentences that
describe the main-only fallback and audit.

The rebase onto #16567 keeps main's memory_pressure entry in
QUEUED_KIND_TEXT, so a later read of a row the pressure hold keeps
still names the pressure instead of "waiting to start". The main
handle's trusted wait identity (#15022) gains a behavioural pin: an
identity that is not provenance-verified must not name kirocrew-core
on the dispatch snapshot.

Backports the fixes for #14877, #15131, #15011 and #15045.

Co-authored-by: Raymond Chen <45910466+chenmingwei23@users.noreply.github.com>
Co-authored-by: Will Laws <will.laws@me.com>
Co-authored-by: Matt Cohen <mattcohe@amazon.com>
(cherry picked from commit 0f785ef)
(cherry picked from commit 4bb1d11)
(cherry picked from commit 6d99710)
(cherry picked from commit c759e04)
bolichen97 added a commit that referenced this pull request Oct 4, 2026
Four main fixes for what users on 0.8 hit with parallel subagents:

- #14878: a wave's "N waiting to start" count ends at "1 waiting" under
  a finished turn, because a popped but unclaimed row was counted once
  more than the window holds. A popped row is now marked dispatching
  and left out of the count, so the last pop publishes 0.
- #16191: the count is re-published after every terminal, Stop all and
  stage Cancel, coalesced per parent; a failed store read publishes
  nothing instead of a false 0; a resident resume entry and a deferred
  spawn_async row are counted correctly; the pump's idle wake no longer
  spins (carries Matt Cohen's #15376 commit).
- #15022: a subagent inside the wait tool is not reaped as stalled
  before its declared duration.
- #16012: a spawn the memory gate deferred exists only as a task-store
  row, so spawn_status answered 404, spawn_list left it out and
  spawn_sub_agents reported it as an error, which made the model
  dispatch the work again. These ids now answer as queued, and the
  sub-agent synthesis waits while a sibling is still queued.

Backport to release/0.8.0. #14878 and #15022 apply cleanly. #16012 is
applied before #16191, its order on main, because #16191 was built on
it. #16012's conflicts are resolved against 0.8 code:
- api_spawn_list has no persisted half and no per-row audit on 0.8, so
  the queued half is listed beside the live half only.
- The persistence fallback of GET /api/spawn/{id} keeps 0.8's shape (a
  run folder reads done); the "no recorded ending is not done" change
  needs main's ending classifier and is left out.
- The Slack gateway and chat runner keep 0.8's orchestrator mode, so
  the synthesis arm stays chat-mode only.
The tests that read main-only APIs are adapted to those shapes, and
test/conftest.py gains main's close_subagent_managers fixture, which
the new tests request. The subagent spec drops the sentences that
describe the main-only fallback and audit.

The rebase onto #16567 keeps main's memory_pressure entry in
QUEUED_KIND_TEXT, so a later read of a row the pressure hold keeps
still names the pressure instead of "waiting to start". The main
handle's trusted wait identity (#15022) gains a behavioural pin: an
identity that is not provenance-verified must not name kirocrew-core
on the dispatch snapshot.

Backports the fixes for #14877, #15131, #15011 and #15045.

Co-authored-by: Raymond Chen <45910466+chenmingwei23@users.noreply.github.com>
Co-authored-by: Will Laws <will.laws@me.com>
Co-authored-by: Matt Cohen <mattcohe@amazon.com>
(cherry picked from commit 0f785ef)
(cherry picked from commit 4bb1d11)
(cherry picked from commit 6d99710)
(cherry picked from commit c759e04)
bolichen97 added a commit that referenced this pull request Oct 5, 2026
Four main fixes for what users on 0.8 hit with parallel subagents:

- #14878: a wave's "N waiting to start" count ends at "1 waiting" under
  a finished turn, because a popped but unclaimed row was counted once
  more than the window holds. A popped row is now marked dispatching
  and left out of the count, so the last pop publishes 0.
- #16191: the count is re-published after every terminal, Stop all and
  stage Cancel, coalesced per parent; a failed store read publishes
  nothing instead of a false 0; a resident resume entry and a deferred
  spawn_async row are counted correctly; the pump's idle wake no longer
  spins (carries Matt Cohen's #15376 commit).
- #15022: a subagent inside the wait tool is not reaped as stalled
  before its declared duration.
- #16012: a spawn the memory gate deferred exists only as a task-store
  row, so spawn_status answered 404, spawn_list left it out and
  spawn_sub_agents reported it as an error, which made the model
  dispatch the work again. These ids now answer as queued, and the
  sub-agent synthesis waits while a sibling is still queued.

Backport to release/0.8.0. #14878 and #15022 apply cleanly. #16012 is
applied before #16191, its order on main, because #16191 was built on
it. #16012's conflicts are resolved against 0.8 code:
- api_spawn_list has no persisted half and no per-row audit on 0.8, so
  the queued half is listed beside the live half only.
- The persistence fallback of GET /api/spawn/{id} keeps 0.8's shape (a
  run folder reads done); the "no recorded ending is not done" change
  needs main's ending classifier and is left out.
- The Slack gateway and chat runner keep 0.8's orchestrator mode, so
  the synthesis arm stays chat-mode only.
The tests that read main-only APIs are adapted to those shapes, and
test/conftest.py gains main's close_subagent_managers fixture, which
the new tests request. The subagent spec drops the sentences that
describe the main-only fallback and audit.

The rebase onto #16567 keeps main's memory_pressure entry in
QUEUED_KIND_TEXT, so a later read of a row the pressure hold keeps
still names the pressure instead of "waiting to start". The main
handle's trusted wait identity (#15022) gains a behavioural pin: an
identity that is not provenance-verified must not name kirocrew-core
on the dispatch snapshot.

Backports the fixes for #14877, #15131, #15011 and #15045.

Co-authored-by: Raymond Chen <45910466+chenmingwei23@users.noreply.github.com>
Co-authored-by: Will Laws <will.laws@me.com>
Co-authored-by: Matt Cohen <mattcohe@amazon.com>
(cherry picked from commit 0f785ef)
(cherry picked from commit 4bb1d11)
(cherry picked from commit 6d99710)
(cherry picked from commit c759e04)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant