Skip to content

fix(subagent): backport the 2 GiB spawn floor to 0.8 - #16315

Merged
bolichen97 merged 2 commits into
release/0.8.0from
backport/0.8.0-subagent-2gib-floor
Oct 3, 2026
Merged

bolichen97 merged 2 commits into
release/0.8.0from
backport/0.8.0-subagent-2gib-floor

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: (release/0.8.0 backport of #15890 and #15929) on 0.8, a 16 GB laptop can start subagents again instead of leaving them queued, and a deferral caused by unreadable cgroup usage says the headroom is unknown.

On release/0.8.0 the spawn floor defaults to 4.0 GB, and every start adds a flat 0.5 GB. A first start therefore needs 4.5 GB available. A 16 GB laptop with a browser and an IDE open rarely has that much, so subagents sit in the queue (#15244). The flat price is also wrong in both directions: a start that shares its parent's runtime is charged as if it were a process, and a dedicated runtime with the default agent's MCP servers settles near 1 GB, not 0.5 GB.

Separately, when a finite cgroup memory limit has a usage file that cannot be read, headroom computes as zero. The resulting deferral reads "low memory: 0.0 GB available", which looks like real exhaustion (#12285).

Why it matters

0.8 is the line users install. Until the next 0.8 tag carries this, those users get none of the main fix, and subagents on a typical 16 GB machine keep waiting for memory they will never get. The misleading cgroup message sends container operators after a memory problem they do not have.

Not a goal

What changed (motivation → approach → change)

This PR implements mainline-plan unit R1 / G2 (fix(subagent): backport the 2 GiB spawn floor to 0.8). It has two commits, each a cherry-pick -x of a merged main PR, with original authorship and Co-authored-by trailers kept.

The product decision (the 2.0 GB floor) is recorded on main in rfc-overload-resilience.md Q9 (accepted, #15887). Q10 there (accepted) adds the macOS veto as part of the same floor rule.

1. 0288a888d4 (#15890): admit on a 2 GiB floor and price each start by how it runs.

  • The floor now means what must remain after a start. It defaults to 2.0 GB from the single constant constants.DEFAULT_SPAWN_MIN_MEMORY_GB. All four former 4.0 sites read it: config/sections.py, config/loader.py, subagent.py (two) and subagent_manager/admission/gate.py.
  • A stored 4.0 adopts to 2.0 once, through a config/superseded_defaults.py row with auto_adopt=True.
  • Each start is priced by its run's own sharing decision:
    • dedicated: the agent's learned settled PSS (capped), or a measured 1.0 GB, and never below subagent_cost_gb;
    • shared: that price less the 0.35 GB process it skips.
  • A shared start that turns dedicated is re-priced and re-checked before its process launches.

Six files conflicted on 0.8. They were resolved as follows:

2. f38d63f988 (#15929): say when a spawn deferral comes from unreadable cgroup usage. This applied cleanly. The cgroup probe records a per-thread cause, and the gate reads it right after its memory check. The warning, refusal text, deferral reason and audit metadata now say the headroom is unknown. Admission is unchanged: the run is still deferred.

Spec updates in this PR: docs/system-specs/modules/subagent.md, docs/architecture/resource-protection.md, docs/request-for-change/rfc-overload-resilience.md (limits table only).

Release gating: the next 0.8 tag must also carry the macOS pressure veto

Do not cut a 0.8 tag that ships this floor to 16 GB Macs without the macOS pressure veto (the #15876 backport, mainline-plan R2). On macOS, available memory includes reclaimable pages, so a 2.0 GB floor alone can admit a start while the kernel already reports memory pressure. Main's RFC records the veto as part of the 2.0 GB floor rule (Q10). This PR can merge on its own, but the tag that releases it must also include R2.

Backwards compatibility

Compatible. Nothing that 0.8 accepts today is rejected, renamed or removed. agent.spawn_min_memory_gb keeps its key and type. Only the default changes, and an explicitly stored 4.0 adopts to 2.0 once through the existing superseded-defaults mechanism. Any other stored value is kept as is. The cost record gains a settled_gb field next to the unchanged mem_gb peak; readers of mem_gb are not affected.

Tests

All of these come from the cherry-picked commits and run on the branch:

  • test/test_spawn_floor_defaults.py (F2/F3) drives the real SubagentManager.spawn path at the shipped defaults:
    • 4.5 GiB admits the first and second dedicated starts;
    • 2.4 GiB queues a dedicated start;
    • a shared start admits where a dedicated one waits;
    • every default of the floor is the one constant.
      On plain release/0.8.0 this file fails at collection (ImportError: DEFAULT_SPAWN_MIN_MEMORY_GB).
  • test/test_config_superseded_defaults.py: a stored 4.0 adopts to 2.0 once.
  • test/test_admission_gate.py:
    • TestSpawnAdmissionGate::test_the_pending_start_is_priced_at_its_dedicated_projection;
    • TestALearnedWholeTreePeakNeverPricesAStart: a learned whole-tree p90 never prices a start.
  • test/test_session_sharing.py::TestSessionSharingFallback::test_a_dedicated_start_is_repriced_before_its_process_launches[fallback|dedicated-arm] pins the run.py top-up in both arms. A review mutation confirmed each variant fails when its top-up is removed.
  • test/test_spawn_memory_cause.py: an unreadable cgroup usage file is reported as unknown headroom.
  • test/test_subagent_sizing.py, test/test_subagent_cost.py: start pricing and the settled-PSS capture.

Local results, after rebasing onto 3d390545fe:

  • The 13 touched test files: 1268 passed, 27 skipped.
  • test_config*, test_docs*, test_resource*: 2183 passed, 34 skipped.
  • Static gates: isort and flake8 are clean on the touched files, and mypy src/kiro_crew passes. Also passing: subprocess-encoding, docs-lint, the harness-parity gate (base release/0.8.0) and the comment-history gate (base release/0.8.0).
  • check_black_formatting.py flags one file, test/test_symlinked_home_member_sources.py. This PR does not touch it, and it fails the same way on plain release/0.8.0 (it came in with fix(members): read member sources on a home reached through a symlink (release/0.8.0) #16265).

Manual verification

N/A: unit coverage is sufficient. The spawn-floor scenarios run the real SubagentManager.spawn admission path with only the memory probe faked. The behaviour is identical to main, where these PRs have already been merged and exercised.

Related Issues

Fixes #15244 (release/0.8.0). Fixes #12285 (release/0.8.0). Main: #15890, #15929.

Depends on: nothing to merge. Release dependency: the macOS pressure veto backport (#15876, mainline-plan R2) must ride in the same 0.8 tag.

Pattern harvest

Not generalizable: this is a backport. The pattern harvest for the defect (one constant behind every default of a threshold, pinned by test_every_default_of_the_floor_is_the_one_constant) was done in #15890.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

@bolichen97
bolichen97 requested a review from a team as a code owner October 2, 2026 23:38
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 2, 2026
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ human override accepted

@bolichen97 overrode this lane for 6654bbfb786f67ddce9b05d94eb3ec7beaa2efde via /ai-review override (this commit only).

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

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

Design-Verdict: CONCERNS

The macOS pressure-veto release dependency lives only in PR prose; nothing on the branch stops a 0.8 tag shipping the 2 GiB floor alone.

Watch

  • The description itself states the hazard: "a 2.0 GB floor alone can admit a start while the kernel already reports memory pressure" on macOS, and gates the tag on the fix(subagent): veto macOS starts under kernel memory pressure #15876 backport (R2) — but that gate is enforced by nothing a tag-cutter following docs/build/release.md would hit. Whoever cuts the next 0.8 tag without reading this PR ships the floor to 16 GB Macs with the veto missing, exactly the regression Q10 exists to prevent.
    Clears when: R2 merges to release/0.8.0 before the next tag, or the dependency is recorded somewhere the release flow mechanically consults (a release-blocking issue/milestone on the 0.8 tag, not PR prose).

Suggestions

  • Open the release-blocking tracker for R2 now, in the same breath as merging this, so the gate exists before anyone can forget it.

[DESIGN-REVIEWED] 6654bbf

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ human override accepted

Human judgment by @bolichen97 overrides the GPT 5.6 finding for 6654bbfb786f67ddce9b05d94eb3ec7beaa2efde; the recorded reason is authoritative for this commit.

[GPT-OVERRIDE] 6654bbf

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:
/ai-review override gpt 6654bbfb786f67ddce9b05d94eb3ec7beaa2efde: <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
@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 6654bbfb786f67ddce9b05d94eb3ec7beaa2efde — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 6654bbf

Verdict parsed from the review's SHA-scoped output markers for commit 6654bbfb786f67ddce9b05d94eb3ec7beaa2efde.

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

bolichen97 and others added 2 commits October 3, 2026 02:27
…runs (#15890)

The spawn floor defaulted to 4.0 GB with one flat 0.5 GB per start on top,
so a 16 GB laptop rarely had the 4.5 GB a first start needed and subagents
sat in the queue. The flat price was also wrong both ways: a start that
shares its parent's runtime was charged as a process, and a dedicated
runtime with the default agent's MCP servers settles near 1 GB.

The floor now means what must remain AFTER a start, default 2.0 GB from one
constant behind every consumer; a stored 4.0 adopts to 2.0 once. Each start
is priced by its run's own sharing decision and carries that price until it
settles: dedicated at the agent's learned settled PSS (capped) or a measured
1.0 GB, never below subagent_cost_gb; shared at that less the 0.35 GB process
it skips. A shared start that turns dedicated is re-priced and re-checked
before its process launches. Pending claims are charged their checked price.
The learned settled size is a new quiet PSS capture per dedicated process,
written as the cost record's settled_gb beside the unchanged mem_gb peak.

RFC overload-resilience Q9 (#15887) records the decision and supersedes Q8.

Backport to release/0.8.0: the RFC on this branch has no Q8 or Q9, so its
limits table takes the new spawn-floor and posture rows without the Q9
pointer. run.py keeps 0.8's claim path (no claim-time re-projection) and
gains only the dedicated top-up and the shared-flag reset. The whole-tree
p90 admission test that #15247 left out comes along with its new price.
That test and the run.py top-up test close their manager at teardown,
so neither leaves the durable task store open.

Fixes #15244

Co-authored-by: Raymond Chen <45910466+chenmingwei23@users.noreply.github.com>
(cherry picked from commit 0288a88)
… usage (#15929)

A finite cgroup memory limit whose usage file cannot be read gives zero
headroom, so the spawn gate defers the run. The deferral then read
"low memory: 0.0 GB available", which looks like real exhaustion.

The cgroup probe now records a per-thread cause when it hits that case,
and the gate reads it right after its own memory check. The warning, the
refusal text, the deferral reason and the audit metadata now say the
headroom is unknown and ask to restore read access to memory.current /
memory.usage_in_bytes. Admission is unchanged: the run is still deferred.

Backport to release/0.8.0: the new test file closes every manager it
builds at teardown, so none leaves the durable task store open.

Closes #12285

Co-authored-by: Joe Guo <zejiangg@amazon.com>
(cherry picked from commit f38d63f)
@bolichen97
bolichen97 force-pushed the backport/0.8.0-subagent-2gib-floor branch from 616bf31 to 6654bbf Compare October 3, 2026 02:27
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 3, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=100e7e6ee854 new managers leak process-lifetime resources: FIXED in 6654bbf

Fixed. Each manager these tests build now closes at teardown. test_spawn_memory_cause.py gets the autouse _close_subagent_managers fixture (the same shape test_subagent_sizing.py uses). The two tests this backport adds, TestALearnedWholeTreePeakNeverPricesAStart and test_a_dedicated_start_is_repriced_before_its_process_launches, register request.addfinalizer(mgr.close). The fix is folded into the commit that introduced each test, so the PR still has two commits and both keep their authors.
Evidence: a probe plugin counted the open fds pointing at tasks.db after each test's teardown. Before the fix the count climbed 3 per manager, from 3 to 15 across test_spawn_memory_cause.py plus the admission-gate test, and each session-sharing variant held 3. After the fix every one of those 13 tests reads 0.
The test/test_subagent_sizing.py:962 site was already covered: that module's autouse _close_subagent_managers fixture closes every _mgr(). The same probe reads 0 after all 131 of its tests, so nothing changed there.
The 13 touched test files: 1268 passed, 27 skipped.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=599ab81e58eb cgroup walk falls back onto the event loop: REBUTTED, no change

Kept as is. This is the documented design of _host_available_gb_off_loop, and it is byte-identical to main's merged #15890 (same function, same _HOST_READ_OFF_LOOP_SECS = 2.0). The fallback is the same synchronous read the admission gate already makes on the loop for every spawn (subagent_manager/admission/gate.py), so it adds no new kind of stall. The poll it serves is serialized by _dedicated_topup_lock and bounded at 60 s.
The proposed sentinel would make avail < 0 fail open in run.py's top-up loop. A dedicated process would then start with no floor check exactly when the executor is saturated, which tends to coincide with memory pressure. That removes the back-pressure this change adds. The lane's own adjudication downgraded this finding for the same reason (disproportionate-remedy).
Any change to this trade belongs on main first. This PR is a backport and should not diverge from main's runtime code.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=8ac28ea2d88f a 0.8 tag can ship this floor without the macOS pressure veto: ACCEPTED, deferred to the release gate

Agreed: the next 0.8 tag must carry the #15876 macOS pressure-veto backport (mainline-plan R2) together with this floor. The "Release gating" section of the PR description says so, and it stays there. This round's report to the release orchestrator also flags that R2 blocks the next 0.8 tag.
This PR does not add a mechanical tag gate, because the release line has no per-feature tag gate to extend. The concern clears when R2 merges to release/0.8.0, as the lane says. Merging this PR alone leaves release/0.8.0 safe to develop on, since nothing is released until a tag is cut.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=0e8f01c7e668 the 2.0 GB floor's decision record (Q9) exists only on main: ACCEPTED, record stays on main

A backport carries a decision main has already accepted onto the release line. The 2.0 GB floor is accepted as RFC overload-resilience Q9 (#15887) on main, and the PR links it. Porting #15887's docs-only RFC decision text is an explicit non-goal. The release branch's RFC is a frozen snapshot, so rewriting its decision log on a maintenance line would create a second copy of the record that could drift from main.
The behavioural docs this change affects do ship on the branch, in the same commit: docs/system-specs/modules/subagent.md, docs/architecture/resource-protection.md, the RFC limits table and the user-facing config help. They state the new floor's meaning. The verdict is CONCERNS (advisory). It is left for a maintainer to confirm that the main-side record covers the backport.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=599ab81e58eb timeout retries blocking filesystem reads on the event loop: REBUTTED, no change; maintainer override requested

Kept byte-identical to main. _host_available_gb_off_loop is main's merged #15890 code, unchanged at main HEAD. It was itself the fix for an earlier GPT round's event-loop finding on #15890 (disposition 5941545631 there). Main pins the synchronous fallback deliberately in test_a_pool_that_cannot_answer_gets_the_synchronous_reading[stuck|refuses-a-thread]: an unanswered off-loop read must never be taken as "below the floor".
The suggested avail = -1.0 fails open at run.py's top-up loop. A dedicated process would then start with no floor check exactly under the contention that caused the timeout. The adjudicator rates the harm LOW to MEDIUM and upholds only because the AUTOSDE rule is flagged blocking.
The fallback is the same few-file read the admission gate already makes on the loop for every spawn (subagent_manager/admission/gate.py). It runs only after a 2 s off-loop timeout, one row at a time under _dedicated_topup_lock, and within a 60 s bound.
If the trade should change (for example, an unanswered read counts as "no reading this poll" and keeps waiting until the deadline), that belongs on main first and then gets backported. A release-line-only runtime change would make release/0.8.0 diverge from main's pinned behaviour.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=3dc01fa4a21b product-shape change without accepted RFC on the base: REBUTTED; maintainer override requested

The decision is accepted: RFC overload-resilience Q9 (#15887, merged on main 2026-10-01, owner direction) sets the 2.0 GB floor, and Q10 adds the macOS veto. This PR backports two main fixes that implement it.
The release branch's RFC is a frozen snapshot that stops at Q7. Porting #15887 is an explicit non-goal. Its Q9 text supersedes a Q8 that 0.8 never carried, and it describes main-only behaviour, so carrying it would need a reworded second copy of the decision record that could drift from main.
What ships on this branch is what the floor does, in the same commit: subagent.md, resource-protection.md, the RFC limits table and the config help.
This is the coverage call the lane leaves to a maintainer. If a maintainer prefers the record on the base instead of an override, the path is a separate docs-only backport of #15887 to release/0.8.0, followed by a rebase here.

@bolichen97

Copy link
Copy Markdown
Contributor Author
  • span=6db8675f57c7 blocker: the floor's decision lives in main's Q9, not on the base RFC: REBUTTED; maintainer override requested

This is the same root cause as the "Not justified as shipped" item, and it gets the same answer. The lane itself says "No subtraction: the code is a faithful backport of an accepted main decision". The only open question is where the decision record lives.
Main holds the canonical record (Q9, #15887). The limits-table row on this branch documents behaviour that ships here, and the branch's behavioural specs carry the new semantics. The decision is for a maintainer: override, or a separate docs-only #15887 backport onto release/0.8.0 followed by a rebase.

@bolichen97

Copy link
Copy Markdown
Contributor Author

The dependency now lives where a tag-cutter will see it: release-blocking issue #16363 (label blocked). It says the next 0.8 tag must not ship #16315 without the R2 backport of #15876, which is still open on main.
The PR description keeps its "Release gating" section. Merging this PR does not release anything; only a tag does. That matches the lane's clears-when condition ("a release-blocking issue ... not PR prose").

@bolichen97

Copy link
Copy Markdown
Contributor Author

Opened #16363 (label blocked) before this PR merges. It tracks #15876 landing on main, the R2 backport to release/0.8.0, and the rule that no 0.8 tag is cut from a head that has #16315 without R2.

@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

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 6654bbf: faithful backport. The synchronous fallback in _host_available_gb_off_loop is merged main code (#15890), byte-identical and pinned by test_a_pool_that_cannot_answer_gets_the_synchronous_reading. Any change to it lands on main first and is then backported, not changed only on the release branch.

@bolichen97

Copy link
Copy Markdown
Contributor Author

/ai-review override first-principles 6654bbf: the 2 GiB floor is an accepted decision on main (rfc-overload-resilience Q9, #15887, owner decision 2026-10-01). This PR backports the code faithfully; porting the RFC decision text to the frozen 0.8 snapshot is a non-goal.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Human judgment recorded

@bolichen97 marked the gpt AI finding as false positive, not applicable, or explicitly accepted for 6654bbfb786f67ddce9b05d94eb3ec7beaa2efde.

faithful backport. The synchronous fallback in _host_available_gb_off_loop is merged main code (#15890), byte-identical and pinned by test_a_pool_that_cannot_answer_gets_the_synchronous_reading. Any change to it lands on main first and is then backported, not changed only on the release branch.

This decision applies only to this commit. A new push requires a new judgment.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Human judgment recorded

@bolichen97 marked the first-principles AI finding as false positive, not applicable, or explicitly accepted for 6654bbfb786f67ddce9b05d94eb3ec7beaa2efde.

the 2 GiB floor is an accepted decision on main (rfc-overload-resilience Q9, #15887, owner decision 2026-10-01). This PR backports the code faithfully; porting the RFC decision text to the frozen 0.8 snapshot is a non-goal.

This decision applies only to this commit. A new push requires a new judgment.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention labels Oct 3, 2026
@bolichen97
bolichen97 merged commit 1fae716 into release/0.8.0 Oct 3, 2026
23 of 25 checks passed
@bolichen97
bolichen97 deleted the backport/0.8.0-subagent-2gib-floor branch October 3, 2026 04:53
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 3, 2026
bolichen97 added a commit that referenced this pull request Oct 3, 2026
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)
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.

2 participants