CL-7007: Give retained sessions their own retention cap - #628
Merged
TheGreatAxios merged 1 commit intoAug 24, 2026
Merged
Conversation
pruneCompleted's maxCompleted is a TUI display cap (default 20); CL-7002 correctly removed retained sessions' unbounded exemption from it, but that folded reusable-session retention into the same 20-item cap, so resume_agent on an early worker failed with a bare not_found past 20 spawned workers. Open retained sessions (retained:true, lifecycleStatus completed/interrupted) are now excluded from maxCompleted and bounded instead by a separate maxRetained cap (default 50, sized for fan-out), evicting least-recently-used first and never evicting a running session. Eviction still releases sidecars/ reactor/lock entry via releaseHandles, and leaves a tombstone so resume_agent/ followup_task/close_agent report an actionable terminal status plus a read_agent_trace pointer instead of not_found. Updated three CL-7001/CL-7002 tests that had encoded "retained sessions share the display cap" as correct behavior to instead assert the new maxRetained bound.
TheGreatAxios
enabled auto-merge (squash)
August 24, 2026 15:34
TheGreatAxios
added a commit
that referenced
this pull request
Aug 27, 2026
pruneCompleted's maxCompleted is a TUI display cap (default 20); CL-7002 correctly removed retained sessions' unbounded exemption from it, but that folded reusable-session retention into the same 20-item cap, so resume_agent on an early worker failed with a bare not_found past 20 spawned workers. Open retained sessions (retained:true, lifecycleStatus completed/interrupted) are now excluded from maxCompleted and bounded instead by a separate maxRetained cap (default 50, sized for fan-out), evicting least-recently-used first and never evicting a running session. Eviction still releases sidecars/ reactor/lock entry via releaseHandles, and leaves a tombstone so resume_agent/ followup_task/close_agent report an actionable terminal status plus a read_agent_trace pointer instead of not_found. Updated three CL-7001/CL-7002 tests that had encoded "retained sessions share the display cap" as correct behavior to instead assert the new maxRetained bound.
TheGreatAxios
added a commit
that referenced
this pull request
Aug 27, 2026
pruneCompleted's maxCompleted is a TUI display cap (default 20); CL-7002 correctly removed retained sessions' unbounded exemption from it, but that folded reusable-session retention into the same 20-item cap, so resume_agent on an early worker failed with a bare not_found past 20 spawned workers. Open retained sessions (retained:true, lifecycleStatus completed/interrupted) are now excluded from maxCompleted and bounded instead by a separate maxRetained cap (default 50, sized for fan-out), evicting least-recently-used first and never evicting a running session. Eviction still releases sidecars/ reactor/lock entry via releaseHandles, and leaves a tombstone so resume_agent/ followup_task/close_agent report an actionable terminal status plus a read_agent_trace pointer instead of not_found. Updated three CL-7001/CL-7002 tests that had encoded "retained sessions share the display cap" as correct behavior to instead assert the new maxRetained bound.
TheGreatAxios
deleted the
cl-7007-retained-sessions-are-evictable-at-maxcompleted20-so
branch
August 28, 2026 00:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
spawn_agent, resumable viaresume_agent/followup_task) were sharingpruneCompleted'smaxCompleted(a TUI display cap, default 20) with every other finished session, a side effect of CL-7002's correct removal of their previous unbounded exemption. Past 20 spawned workers,resume_agenton an early one failed with a barenot_found.maxRetained(default 50), a separate cap sized for fan-out, governing only open retained sessions (retained:true,lifecycleStatuscompleted/interrupted).maxCompletednow excludes these and continues to bound every ordinary finished session exactly as before.maxRetainedpicks least-recently-used, never evicts arunningsession, and still callsreleaseHandles(sidecars/reactor/lock entry) exactly likepruneCompleted's eviction.resume_agent/followup_task/close_agentreport an actionable terminal status plus aread_agent_tracepointer instead ofnot_found.SubAgentSession.retainedclaiming an exemption frompruneCompleted's cap that no longer exists.maxRetainedresolution guards non-finite/undefined config (including a JSON round-trip turning a configuredInfinityintonull) so it can never silently collapse to0.Tests changed and why
Three existing tests encoded "retained sessions share the display cap" as correct behavior — that was exactly this ticket's defect, so they were updated rather than left to falsely pass:
session-store.test.ts:pruneCompleted evicts a retained, still-open session past maxCompleted...→pruneRetained evicts a retained, still-open session past maxRetained.... Added a companion assertingmaxCompletedstill evicts an ordinary (non-retained) session.agent-fleet.test.ts:reports survive well past the session store's display cap (20)...previously asserted the earliest of 25 spawned retained sessions was evicted from the store; now asserts it is not (25 < defaultmaxRetained50).retain-salvage.test.ts:retained completed sessions are exempt from the display cap without bound→...bounded by maxRetained, not the display cap, now configuringmaxRetainedinstead of relying onmaxCompleted.New tests added (session-store.test.ts): resume_agent on an evicted session returns actionable status + hint; a running session is never evicted by
maxRetained;maxRetainedbounds memory across 50 spawned-and-completed retained sessions.Test plan
bun test src/subagent/session-store.test.ts src/subagent/agent-fleet.test.ts src/subagent/lifecycle-tools.test.ts src/subagent/retain-salvage.test.ts— all passbun run check(lint, typecheck, build, full test suite) — 5294 pass, 0 fail