Repository navigation
Retain only the last 20 worker threads per orchestrator (#213) - #328
Merged
currentbits merged 1 commit intoAug 17, 2026
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
currentbits
deleted the
coder/orchestrator-worker-threads-are-never-de-539a7e
branch
October 3, 2026 16:07
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.
Closes #213.
Why
services.forkWorkerThreadmints a thread plus emptymessagesByThread/workLogByThreadkeys on every fork, and finished workers were only ever archived (sweepCrewinelectron/runner.js), never deleted. An 8-worker fan-out is a normal pattern here, so one orchestrated session per weekday works out to roughly 1,000-2,000 leftover worker threads a year, each carrying its own transcript. Same store-blob pressure as #134 and #124, just slower.What changed
Retention now runs inside
sweepCrew— the one function both worker-minting paths (orchServer'sthread_forktool and the runner'spendingForkdispatch) already settle through, since both go viaservices.forkWorkerThreadand inheritorchWorker+handoffFrom. That provenance was enough to identify workers, so no new field was added.MAX_WORKERS_PER_ORCHESTRATOR = 20, newest-first with an insertion-index tie-break for same-millisecond forks — the same shape aspruneAutomationThreadslanded for #134. A worker is deleted via the existingservices.purgeThread(which drops the thread with its messages, work log and usage) only when all of these hold:done/failed/stopped— never an idle, queued or in-flight threadactivemapworktreePathpinnedAtSkipped threads still occupy a keep slot, matching #134. The
worktreePathguard is not a permanent exemption:worktrees.jsclears it on merge or remove, so an integrated worker becomes prunable on the next sweep.Tests
Three cases in
electron/test/orchestrator-threads.test.js, covering the cap (with the purged threads'messagesByThreadentries verified gone), the working / worktree'd / pinned skips, and non-interference with hand-made threads and a second orchestrator's crew. They drive the prune throughcreateRunner's boot sweep so they exercise the shippedsweepCrewrather than a copy of the logic.npm run test:electron: 901 of 902 pass. The single failure is the pre-existingweb-integration.test.jsreconnect baseline on main, not this change.Deliberately out of scope
Filtering archived workers out of
listThreads/threadSummaries. Capping the crew at 20 caps what those return; worth its own issue if the list still reads as noisy.Nested crews: purging a worker that itself orchestrated a crew orphans that crew's
handoffFrom.sidebarGroupsalready tolerates an absent source and the nested crew carries its own cap, so those transcripts survive until their own orchestrator sweeps.PR created by the Claude Code agent