fix: only resolve run-session when root session goes idle, not subagent sessions#600
fix: only resolve run-session when root session goes idle, not subagent sessions#600kilo-code-bot[bot] wants to merge 1 commit intomainfrom
Conversation
…nt sessions The onSessionStatusChanged callback in run-session.ts resolved the session as done when *any* session went idle. When a subagent (child session) finished, it emitted an idle status event too, causing premature resolution with the subagent's partial result. Pass sessionID through the onSessionStatusChanged callback so consumers can distinguish which session changed status, and check that only the root session's idle event triggers resolution in run-session.ts.
| }, | ||
|
|
||
| onSessionStatusChanged: status => { | ||
| onSessionStatusChanged: (status, _sessionId) => { |
There was a problem hiding this comment.
WARNING: Idle status from child sessions can prematurely end root streaming
This callback now receives sessionId but ignores it. If a subagent/child session emits status.type === 'idle', this will set isStreaming to false and call onStreamComplete for the parent flow too early. Consider gating completion to the active/root session ID, similar to the safeguard added in run-session.ts.
| }, | ||
|
|
||
| onSessionStatusChanged: status => { | ||
| onSessionStatusChanged: (status, _sessionId) => { |
There was a problem hiding this comment.
WARNING: Stream completion can be triggered by non-root session idle events
onSessionStatusChanged now provides sessionId, but this handler still marks streaming complete on any idle. In multi-session/subagent execution, an idle child session can incorrectly flip root UI state and fire onComplete early. Consider checking the event sessionId against the active/root session before completing.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Fix these issues in Kilo Cloud Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (5 files)
|
|
Superseded by #603 |
Summary
runSessionToCompletioninrun-session.tsresolved prematurely when a subagent (child session) went idle, returning the subagent's partial result instead of waiting for the root session to complete.sessionIDthrough theonSessionStatusChangedcallback so consumers can identify which session changed status, and gate resolution inrun-session.tson the root session's idle event only.Changes
src/lib/cloud-agent-next/processor/types.ts: AddedsessionIdparameter toonSessionStatusChangedcallback signature.src/lib/cloud-agent-next/processor/event-processor.ts: DestructuresessionIDfrom the event data and pass it to the callback.src/lib/cloud-agent-next/run-session.ts: Check that the idle event'ssessionIdmatches the rootcloudAgentSessionIdbefore resolving.src/components/cloud-agent-next/useCloudAgentStream.ts: Accept the new_sessionIdparameter (unused).src/components/app-builder/project-manager/sessions/v2/streaming.ts: Accept the new_sessionIdparameter (unused).Built for Remon Oldenbeuving by Kilo for Slack