fix(cloud-agent-next): recover orphaned review sessions#877
Open
alex-alecu wants to merge 5 commits intomainfrom
Open
fix(cloud-agent-next): recover orphaned review sessions#877alex-alecu wants to merge 5 commits intomainfrom
alex-alecu wants to merge 5 commits intomainfrom
Conversation
| const executions = await this.executionQueries.getAll(); | ||
| const candidates = executions | ||
| .filter(execution => execution.status === 'running' || execution.status === 'pending') | ||
| .sort((a, b) => b.startedAt - a.startedAt); |
Contributor
There was a problem hiding this comment.
WARNING: Recovering only the newest non-terminal execution can leave older orphaned executions stuck
If active_execution_id is lost and another execution starts before the alarm fires, both executions can be non-terminal. Picking the newest candidate here restores that marker and causes the older orphan to be ignored on subsequent alarms, because cleanupStaleExecutions() goes back to following the active marker once one exists. That leaves the stale original execution stranded until the newer execution finishes.
Contributor
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Fix these issues in Kilo Cloud Other Observations (not in diff)N/A Files Reviewed (3 files)
|
jeanduplessis
approved these changes
Mar 6, 2026
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
Recover V2 review sessions when a running execution loses
active_execution_id.The production case here looks like a single hidden execution, not intended parallel work in one session. Once the marker was lost, stale reaping, interrupts, alarm cadence, idle Kilo cleanup, and the terminal callback path could all treat the session as idle. This change repairs the active marker from non-terminal execution state and makes those lifecycle checks use the repaired view. The broader scan of non-terminal executions is defensive hardening if marker loss ever lets session state drift.
Verification
pnpm --dir cloud-agent-next exec tsc -p tsconfig.json --noEmit✅pnpm --dir cloud-agent-next test:integration test/integration/session/disconnect-and-reaper.test.ts test/integration/session/start-execution-v2.test.ts✅Visual Changes
N/A
Reviewer Notes
The observed incident is explained by one running execution with a missing marker. Handling multiple non-terminal records here is secondary hardening, not an assumption that parallel executions in one session are expected.