Repository navigation
feat(klaud): park sessions on queued runs and resume when they end / feat(klaud):会话在运行排队时挂起并在运行结束后恢复 #4474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
feat(klaud): park sessions on queued runs and resume when they end / feat(klaud):会话在运行排队时挂起并在运行结束后恢复 #4474
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 After merging, Klaud can run many more concurrent agent sessions than the 5-per-wave cap, because resumes dispatched by wake runs are never counted against new candidates. Each wake pass resumes up to
MAX_CANDIDATES_PER_RUNsessions.selectsubtracts only theresumedcount from its own wave's recover job (slots = max(0, max_candidates - resumed), main.py:944). Fix: make new-candidate slots account for every live resumed session, for example by havingselectsubtract the live Klaud sessions found byowned_activity, or by capping wake resumes to the headroom left by live sessions.Why this was flagged
The new
15,45 * * * *cron (klaud-plan.yml:25) runs therecoverjob 48 times a day, and each run callsrecover --max-resumes "$MAX_CANDIDATES_PER_RUN". That can dispatch up to 5 resume runs per pass (lifecycle.py:1166-1186). Wake runs skipreviewandselect, so these resumes never reduce the next wave's slots. When the 6-hourly wave runs, sessions that were ready to resume have already been picked up by earlier wake passes, so its ownresumedoutput is about 0.selectthen fills all 5 slots with new candidates (main.py:944) while the earlier wake-resumed sessions are still running. On the base branch, resumes happened only in the 6-hourly wave, and select's--resumedmade resumed plus new sessions at most 5 per wave. After this change, the number of concurrent Claude sessions and GPU benchmark runs is limited only by how many candidates are open, and with 12 sessions and indefinite retention more of them stay open longer. No other code counts live sessions against the cap:owned_activityis used only bysweep_abandoned.Verification: klaud-plan.yml:25 adds
cron: '15,45 * * * *', on whichselectis skipped whilerecoverstill resumes up to 5.slots = max(0, max_candidates - resumed)at main.py:944 counts only the resumes made by the same run's recover job. Base comparison (f8eceff): recover ran only in the 6-hourly wave, so resumes and new candidates shared the same 5 slots.