Skip to content

docs(coding-agent): guide completed subagent cleanup - #548

Merged
snimu merged 6 commits into
mainfrom
docs/subagent-runtime-cleanup-guidance
Aug 2, 2026
Merged

snimu merged 6 commits into
mainfrom
docs/subagent-runtime-cleanup-guidance

Conversation

@sethkarten

@sethkarten sethkarten commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • tell the model to retain completed direct children when they may be reused
  • tell the model to delete a completed direct child only once it is definitively no longer needed
  • keep lifecycle cleanup explicit rather than automatically deleting reusable sessions

Tests

  • test/system-prompt.test.ts
  • npm run check

Stacked on #547.


Note

Low Risk
Prompt and changelog-only change; no runtime or API behavior is modified.

Overview
Subagent lifecycle guidance in buildSubagentGuidance now tells the model to keep finished direct children when they might be reused (e.g. via agent_message), and to call await rlm.delete_subagent(child) only after they are clearly no longer needed—making cleanup explicit instead of implying automatic removal of reusable sessions.

The [Unreleased] changelog entry and a system-prompt test assert the new sentence is present in the assembled prompt.

Reviewed by Cursor Bugbot for commit b8365ac. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Retry deleted subagent runtime cleanup after compaction and guide subagent lifecycle

  • Adds _reapDeletedRlmSubagentRuntimesAfterCompaction to AgentSession, which retries deleteRlmSubagent for any pending retryable deletions using Promise.allSettled after each compaction.
  • Updates buildSubagentGuidance to advise retaining reusable completed direct children and explicitly deleting them with rlm.delete_subagent when no longer needed.
  • Adds and updates tests in agent-session-recursion.test.ts and agent-session-compaction.test.ts to cover the new reap-on-compact behavior, including error tolerance.

Macroscope summarized b8365ac.

@snimu snimu left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to release all subagents that aren't currently running on every compaction, so it's only on disk. And then when the main agent wants to use them again, rehydrate that specific subagent.
That would ease the load on the agent and reduce distractions, increase reliability, enable re-using older agents again, and likely save more memory.

@sethkarten
sethkarten force-pushed the docs/subagent-runtime-cleanup-guidance branch from 2e4ca1e to 94c642a Compare August 1, 2026 05:49
@sethkarten
sethkarten requested a review from snimu August 1, 2026 16:27
Base automatically changed from fix/compaction-runtime-gc to main August 2, 2026 09:49
@snimu
snimu merged commit ec4a03b into main Aug 2, 2026
11 checks passed
snimu added a commit that referenced this pull request Aug 3, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 4, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 5, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 5, 2026
Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)
snimu added a commit that referenced this pull request Aug 5, 2026
* feat(coding-agent): intra-tree child session passivation

Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; #548 doctrine
  inversion deferred (prompts out of scope this run)

* fix(coding-agent): harden passivation against new admission fences and reap dedupe

Post-rebase semantic fixes after moving the stack onto the hardened
scheduler base (cb8f53e):

- passivation predicate treats admission-in-flight as busy: agent-message
  accepting/preparing/target-lock states and AgentSession's pending
  admission-fence waiters (70aeb9c/2d97dbb4f made prompt paths await the
  direct-turn admission fence before any session action exists, so a target
  mid-admission looked idle to the sweep); deterministic gated-admission
  regression test
- deleteRlmSubagentRuntime cancels scheduled jobs by session file even when
  its close joins an in-flight passivation close via closingSessions (the
  joined 'shutdown' close skipped 'killed'-close job cleanup; #547 reap race)

* fix(coding-agent): harden passive-child hydration, resolution, and deletion races

- Finding 0: heartbeat restore could return a concurrently hydrating child before binding; fence resident fallback with waitForBoundSession and treat unavailable binding as a skipped dispatch. origin: PR #583
- Finding 1: supervisor child lookup accepted only exact selectors after worker suffix matching; add the same session-ID suffix fallback within the selected worker. origin: PR #583
- Finding 3: passive create hydration skipped explicit name and client environment bookkeeping; apply both before returning the hydrated state. origin: PR #583
- Finding 4: concurrent passive deletions raced through asynchronous resolution and started duplicate host deletes; defer deletion behind an atomic in-flight map check and coalesce callers. origin: PR #583
- Finding 5: concurrent hydration could make a passive lookup stale for advertised IDs and paths; retry normal bound-session resolution before rethrowing the original unknown-session error. origin: PR #583
- Finding 6: ambiguous live selectors fell through to passive lookup and could misroute; introduce a dedicated ambiguity error and rethrow it before passive resolution. origin: PR #583
- Finding 7: passive open skipped name and client-env bookkeeping (cron rebinding already occurred in addRuntime); apply only the missing bookkeeping. origin: PR #583
- Finding 30: rlmChildId traffic treated a resident passivating child as closing; join passivation and rehydrate in both bound lookup and direct message hydration branches. origin: PR #589

* fix(coding-agent): restore attach/catch-up ordering invariants and sweep snapshot atomicity

- Finding 22: async snapshot creation exposed clients before attach initialization; publish client attachment only after the snapshot resolves. origin: PR #587
- Finding 23: catch-up validity was checked only before async snapshot creation; revalidate session and client attachment after the await. origin: PR #587
- Finding 25: deterministic ambiguous selectors entered the 30-second remote-send retry loop; fail fast for Ambiguous errors. origin: PR #588
- Finding 28: active rows ignored stable file-keyed schedule pins during active-id rebinding; consult both id- and file-keyed heartbeat/cron sets. origin: PR #588
- Finding 29: passivation sampled activity before an asynchronous passive-registry walk; complete the walk before atomically sampling summary and admission markers. origin: PR #589

* fix(coding-agent): correct rlmDepth semantics on reference edges, env parsing, and legacy fallbacks

- Finding 8: new-session parent links were deriving spawn depth; copy the source header depth across the reference edge and add a runtime regression test (origin: PR #584).
- Finding 9: first-entry forks of legacy sessions discarded effective runtime depth; fall back to session.rlmDepth in persisted and in-memory branches and test both (origin: PR #584).
- Finding 10: root RLM_DEPTH parsing accepted malformed and unsafe values; require decimal digits and a valid safe non-negative integer, with probe cases as tests (origin: PR #584).
- Finding 11: child-depth derivation could overflow MAX_SAFE_INTEGER; guard the increment and test the boundary (origin: PR #584).
- Finding 12: daemon children of in-memory parents skipped explicit depth persistence; always create the child header with explicit depth and test --no-session ancestry (origin: PR #584).
- Finding 13: legacy completed subagents rehydrated at root depth; restore the depth-one fallback and test a registry/header pair without depth (origin: PR #584).

* fix(coding-agent): make /rlm-max-depth persistence honest and unblock stale kernel gate

- /rlm-max-depth --global could claim persistence after deferred settings write failures; drain and surface global errors before reporting success (origin: PR #585)
- /rlm-max-depth mutated live state before chat persistence and left failed entries indexed; persist first through rollback-safe custom-entry append, then mutate state and prompt (origin: PR #585)
- invalid persisted global rlmMaxDepth could abort branch navigation after the leaf moved; ignore invalid global reads and fall through to env/default (origin: PR #585)
- the kernel-side recursion pre-filter used stale one-shot RLM_MAX_DEPTH and blocked raises before the authoritative host gate; remove the duplicated Python gate (origin: PR #585)

* fix(coding-agent): agents-view scope stability, crash-path backSession, summary refresh, pulse, and settings cycling

- Finding 18: stale saved-catalog readiness could destructively drop scope during refresh; reset readiness when refresh starts. origin: PR #586
- Finding 19: resolved scope roots were lost across view remounts, swallowing early Left navigation; persist and restore the root summary. origin: PR #586
- Finding 20: post-attach crashes left backSession pointing at the prior session; assign the opened summary before interactive mode runs. origin: PR #586
- Findings 21 and 24: startup seeding could leave subagent counts stale and background subagents drove an unused render pulse; refresh every seed and pulse only while streaming. origin: PR #587
- Finding 27: custom idle-eviction values cycled directly to off; include custom numeric values in the sorted cycle. origin: PR #588

* fix(coding-agent): attach reservation vs passivation, binding join on retry, hydration env, settings error scoping, fractional eviction values

- reserve in-flight attaches and revalidate session liveness before attachment (origin: round-1 fix a342ca2)
- join concurrent child binding on the final passive resolution retry (origin: round-1 fix ae3ed45)
- adopt create-command client env before passive child hydration (origin: round-1 fix ae3ed45)
- isolate max-depth write errors while preserving project diagnostics (origin: round-1 fix 9e738f3)
- preserve fractional idle eviction values through settings cycling (origin: round-1 fix 721f45b; stack commit aa98c9a)

* fix(coding-agent): post-rebase hardening of passive hydration, snapshots, and depth ingestion

- preserve daemon routable IDs for passive children (origin: PR #583)
- recheck guarded passive hydration and heartbeat restores (origin: PR #583)
- repair wrong-kind pending hydration joins (origin: PR #583)
- fence passive hydration during update restart preparation (origin: PR #583)
- validate persisted RLM depth before constructor ingestion (origin: PR #584)
- retry attach child snapshots across session replacement (origin: PR #587)
- retain effective depth for legacy parented new sessions (origin: PR #589)
- coordinate parent passivation with child hydration publication (origin: PR #589)

* fix(coding-agent): leave shared passive hydration resident on guard cancellation

The ownership-blind close closed shared hydrations out from under concurrent wakes (both interleavings); the idle sweep is the ownership-free arbiter.

origin: round-4 fix b956400 / PR #583

* fix(coding-agent): prefer persisted header depth for legacy rehydration entries

The legacy-entry rehydration fallback (entry.rlmDepth ?? 1) is passed as
config, which outranks the opened transcript header in AgentSession — so a
nested legacy child whose header carried a deeper persisted depth woke at
depth 1, weakening the host recursion gate. Registry depth stays
authoritative when present; otherwise the validated header depth wins and 1
remains the last-resort default for fully legacy children.

origin: PR #584 fallback restored in round-1 triage; surfaced by post-rebase
bot review of PR #589.

* fix(coding-agent): fence chain hydration against parent passivation; invalidate stale scope roots

* fix(coding-agent): bound the session snapshot stabilization loop

* fix(coding-agent): restore child event forwarder when passivation close fails

Passivation teardown invoked the retained child's event-forwarder
unsubscribe before closing the session. When the close failed and the
child was re-adopted, the forwarder was gone, so a still-resident child
stopped emitting rlm_child_update to its parent. Teardown now returns
the unsubscribe so the passivation path only invokes it after a
successful close and restores it on the failed-close re-adopt path.

* fix(coding-agent): close child passivation races

- Keep snapshot messages aligned with the final runtime session summary after stabilization exhaustion.
- Retry passive child hydration when the child starts passivating inside the hydration window.
- Apply archive and scheduled-job cancellation when kill joins a resume-preserving close.

* fix(coding-agent): upgrade cascading close reasons

- Track the applied close reason and resident descendant states through cascading teardown.
- Apply stronger joined close effects uniformly to parents and captured descendants.
- Cover shutdown-to-killed descendant cleanup and completed-to-killed idempotency.

* fix(coding-agent): preserve passive child id on hydration retry

- Forward the restored active-session ID when retrying after a mismatched pending open.
- Cover the pending-open race through passive-child hydration.

* fix(coding-agent): recover passivation waiters

- Treat failed passivation settlement as a join signal before retrying resident sessions.
- Cover concurrent open, message delivery, and hydration after passivation rejection.

* fix(coding-agent): harden passivation close races

- Preserve stronger close-reason upgrades when the joined close fails.
- Run child passivation outside the supervisor-wide eviction fence.
- Complete reason-upgrade persistence across targets and record the stronger reason before propagating errors.

* fix(coding-agent): preserve passive opener state across races

- Defer root parent client env adoption until passive hydration and its open guard succeed.
- Join opening or resident passive targets when parent-change restart resolution races hydration.
@kevinjosethomas
kevinjosethomas deleted the docs/subagent-runtime-cleanup-guidance branch August 5, 2026 18:53
zhengr pushed a commit to zhengr/prime-agent that referenced this pull request Aug 8, 2026
…ai#548)

* fix(coding-agent): reap deleted subagent runtimes on compaction

* docs(coding-agent): guide completed subagent cleanup

---------

Co-authored-by: Sebastian <sebastian@primeintellect.ai>
zhengr pushed a commit to zhengr/prime-agent that referenced this pull request Aug 8, 2026
…ect-ai#589)

* feat(coding-agent): intra-tree child session passivation

Track A PR 7 (final) of the recursive-agent-harness plan (D5, shape 2):

- idle child sessions inside a LIVE worker passivate individually: graceful
  closeSession (kernel snapshot + JSONL flush + lease release), sessions-map
  removal, registry/catalog rows preserved - the child becomes exactly a
  lazy-hydration passive row (attach/message/observe/list all work)
- pure canPassivateSession() beside canEvictWorker(), sharing its per-
  session clauses; additionally requires a parent edge, no non-passive
  descendants, and no mid-hydration descendant (passive children's
  sessionFiles checked against openingSessions - hydration blocks parent
  passivation); roots remain shape-1 territory; passivation never cascades
- complete-then-rehydrate: touches mid-passivation join the passivation
  promise (keyed by resolved sessionFile - stable across sessions-map
  removal) then flow through the normal hydration machinery; deterministic
  gated race tests for a2a delivery and grandchild hydration
- supervisor sweep extension: capped worker command (2 children/worker/
  sweep), one snapshot per state per sweep, fresh-snapshot fence recheck
  before dispose; whole-tree-evictable workers excluded (owned by shape 1)
- same idleEvictionMinutes setting governs both shapes; PrimeIntellect-ai#548 doctrine
  inversion deferred (prompts out of scope this run)

* fix(coding-agent): harden passivation against new admission fences and reap dedupe

Post-rebase semantic fixes after moving the stack onto the hardened
scheduler base (cb8f53e):

- passivation predicate treats admission-in-flight as busy: agent-message
  accepting/preparing/target-lock states and AgentSession's pending
  admission-fence waiters (70aeb9c/2d97dbb4f made prompt paths await the
  direct-turn admission fence before any session action exists, so a target
  mid-admission looked idle to the sweep); deterministic gated-admission
  regression test
- deleteRlmSubagentRuntime cancels scheduled jobs by session file even when
  its close joins an in-flight passivation close via closingSessions (the
  joined 'shutdown' close skipped 'killed'-close job cleanup; PrimeIntellect-ai#547 reap race)

* fix(coding-agent): harden passive-child hydration, resolution, and deletion races

- Finding 0: heartbeat restore could return a concurrently hydrating child before binding; fence resident fallback with waitForBoundSession and treat unavailable binding as a skipped dispatch. origin: PR PrimeIntellect-ai#583
- Finding 1: supervisor child lookup accepted only exact selectors after worker suffix matching; add the same session-ID suffix fallback within the selected worker. origin: PR PrimeIntellect-ai#583
- Finding 3: passive create hydration skipped explicit name and client environment bookkeeping; apply both before returning the hydrated state. origin: PR PrimeIntellect-ai#583
- Finding 4: concurrent passive deletions raced through asynchronous resolution and started duplicate host deletes; defer deletion behind an atomic in-flight map check and coalesce callers. origin: PR PrimeIntellect-ai#583
- Finding 5: concurrent hydration could make a passive lookup stale for advertised IDs and paths; retry normal bound-session resolution before rethrowing the original unknown-session error. origin: PR PrimeIntellect-ai#583
- Finding 6: ambiguous live selectors fell through to passive lookup and could misroute; introduce a dedicated ambiguity error and rethrow it before passive resolution. origin: PR PrimeIntellect-ai#583
- Finding 7: passive open skipped name and client-env bookkeeping (cron rebinding already occurred in addRuntime); apply only the missing bookkeeping. origin: PR PrimeIntellect-ai#583
- Finding 30: rlmChildId traffic treated a resident passivating child as closing; join passivation and rehydrate in both bound lookup and direct message hydration branches. origin: PR PrimeIntellect-ai#589

* fix(coding-agent): restore attach/catch-up ordering invariants and sweep snapshot atomicity

- Finding 22: async snapshot creation exposed clients before attach initialization; publish client attachment only after the snapshot resolves. origin: PR PrimeIntellect-ai#587
- Finding 23: catch-up validity was checked only before async snapshot creation; revalidate session and client attachment after the await. origin: PR PrimeIntellect-ai#587
- Finding 25: deterministic ambiguous selectors entered the 30-second remote-send retry loop; fail fast for Ambiguous errors. origin: PR PrimeIntellect-ai#588
- Finding 28: active rows ignored stable file-keyed schedule pins during active-id rebinding; consult both id- and file-keyed heartbeat/cron sets. origin: PR PrimeIntellect-ai#588
- Finding 29: passivation sampled activity before an asynchronous passive-registry walk; complete the walk before atomically sampling summary and admission markers. origin: PR PrimeIntellect-ai#589

* fix(coding-agent): correct rlmDepth semantics on reference edges, env parsing, and legacy fallbacks

- Finding 8: new-session parent links were deriving spawn depth; copy the source header depth across the reference edge and add a runtime regression test (origin: PR PrimeIntellect-ai#584).
- Finding 9: first-entry forks of legacy sessions discarded effective runtime depth; fall back to session.rlmDepth in persisted and in-memory branches and test both (origin: PR PrimeIntellect-ai#584).
- Finding 10: root RLM_DEPTH parsing accepted malformed and unsafe values; require decimal digits and a valid safe non-negative integer, with probe cases as tests (origin: PR PrimeIntellect-ai#584).
- Finding 11: child-depth derivation could overflow MAX_SAFE_INTEGER; guard the increment and test the boundary (origin: PR PrimeIntellect-ai#584).
- Finding 12: daemon children of in-memory parents skipped explicit depth persistence; always create the child header with explicit depth and test --no-session ancestry (origin: PR PrimeIntellect-ai#584).
- Finding 13: legacy completed subagents rehydrated at root depth; restore the depth-one fallback and test a registry/header pair without depth (origin: PR PrimeIntellect-ai#584).

* fix(coding-agent): make /rlm-max-depth persistence honest and unblock stale kernel gate

- /rlm-max-depth --global could claim persistence after deferred settings write failures; drain and surface global errors before reporting success (origin: PR PrimeIntellect-ai#585)
- /rlm-max-depth mutated live state before chat persistence and left failed entries indexed; persist first through rollback-safe custom-entry append, then mutate state and prompt (origin: PR PrimeIntellect-ai#585)
- invalid persisted global rlmMaxDepth could abort branch navigation after the leaf moved; ignore invalid global reads and fall through to env/default (origin: PR PrimeIntellect-ai#585)
- the kernel-side recursion pre-filter used stale one-shot RLM_MAX_DEPTH and blocked raises before the authoritative host gate; remove the duplicated Python gate (origin: PR PrimeIntellect-ai#585)

* fix(coding-agent): agents-view scope stability, crash-path backSession, summary refresh, pulse, and settings cycling

- Finding 18: stale saved-catalog readiness could destructively drop scope during refresh; reset readiness when refresh starts. origin: PR PrimeIntellect-ai#586
- Finding 19: resolved scope roots were lost across view remounts, swallowing early Left navigation; persist and restore the root summary. origin: PR PrimeIntellect-ai#586
- Finding 20: post-attach crashes left backSession pointing at the prior session; assign the opened summary before interactive mode runs. origin: PR PrimeIntellect-ai#586
- Findings 21 and 24: startup seeding could leave subagent counts stale and background subagents drove an unused render pulse; refresh every seed and pulse only while streaming. origin: PR PrimeIntellect-ai#587
- Finding 27: custom idle-eviction values cycled directly to off; include custom numeric values in the sorted cycle. origin: PR PrimeIntellect-ai#588

* fix(coding-agent): attach reservation vs passivation, binding join on retry, hydration env, settings error scoping, fractional eviction values

- reserve in-flight attaches and revalidate session liveness before attachment (origin: round-1 fix a342ca2)
- join concurrent child binding on the final passive resolution retry (origin: round-1 fix ae3ed45)
- adopt create-command client env before passive child hydration (origin: round-1 fix ae3ed45)
- isolate max-depth write errors while preserving project diagnostics (origin: round-1 fix 9e738f3)
- preserve fractional idle eviction values through settings cycling (origin: round-1 fix 721f45b; stack commit aa98c9a)

* fix(coding-agent): post-rebase hardening of passive hydration, snapshots, and depth ingestion

- preserve daemon routable IDs for passive children (origin: PR PrimeIntellect-ai#583)
- recheck guarded passive hydration and heartbeat restores (origin: PR PrimeIntellect-ai#583)
- repair wrong-kind pending hydration joins (origin: PR PrimeIntellect-ai#583)
- fence passive hydration during update restart preparation (origin: PR PrimeIntellect-ai#583)
- validate persisted RLM depth before constructor ingestion (origin: PR PrimeIntellect-ai#584)
- retry attach child snapshots across session replacement (origin: PR PrimeIntellect-ai#587)
- retain effective depth for legacy parented new sessions (origin: PR PrimeIntellect-ai#589)
- coordinate parent passivation with child hydration publication (origin: PR PrimeIntellect-ai#589)

* fix(coding-agent): leave shared passive hydration resident on guard cancellation

The ownership-blind close closed shared hydrations out from under concurrent wakes (both interleavings); the idle sweep is the ownership-free arbiter.

origin: round-4 fix b956400 / PR PrimeIntellect-ai#583

* fix(coding-agent): prefer persisted header depth for legacy rehydration entries

The legacy-entry rehydration fallback (entry.rlmDepth ?? 1) is passed as
config, which outranks the opened transcript header in AgentSession — so a
nested legacy child whose header carried a deeper persisted depth woke at
depth 1, weakening the host recursion gate. Registry depth stays
authoritative when present; otherwise the validated header depth wins and 1
remains the last-resort default for fully legacy children.

origin: PR PrimeIntellect-ai#584 fallback restored in round-1 triage; surfaced by post-rebase
bot review of PR PrimeIntellect-ai#589.

* fix(coding-agent): fence chain hydration against parent passivation; invalidate stale scope roots

* fix(coding-agent): bound the session snapshot stabilization loop

* fix(coding-agent): restore child event forwarder when passivation close fails

Passivation teardown invoked the retained child's event-forwarder
unsubscribe before closing the session. When the close failed and the
child was re-adopted, the forwarder was gone, so a still-resident child
stopped emitting rlm_child_update to its parent. Teardown now returns
the unsubscribe so the passivation path only invokes it after a
successful close and restores it on the failed-close re-adopt path.

* fix(coding-agent): close child passivation races

- Keep snapshot messages aligned with the final runtime session summary after stabilization exhaustion.
- Retry passive child hydration when the child starts passivating inside the hydration window.
- Apply archive and scheduled-job cancellation when kill joins a resume-preserving close.

* fix(coding-agent): upgrade cascading close reasons

- Track the applied close reason and resident descendant states through cascading teardown.
- Apply stronger joined close effects uniformly to parents and captured descendants.
- Cover shutdown-to-killed descendant cleanup and completed-to-killed idempotency.

* fix(coding-agent): preserve passive child id on hydration retry

- Forward the restored active-session ID when retrying after a mismatched pending open.
- Cover the pending-open race through passive-child hydration.

* fix(coding-agent): recover passivation waiters

- Treat failed passivation settlement as a join signal before retrying resident sessions.
- Cover concurrent open, message delivery, and hydration after passivation rejection.

* fix(coding-agent): harden passivation close races

- Preserve stronger close-reason upgrades when the joined close fails.
- Run child passivation outside the supervisor-wide eviction fence.
- Complete reason-upgrade persistence across targets and record the stronger reason before propagating errors.

* fix(coding-agent): preserve passive opener state across races

- Defer root parent client env adoption until passive hydration and its open guard succeed.
- Join opening or resident passive targets when parent-change restart resolution races hydration.
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