fix: only resolve session on root session idle, not subagent idle#601
fix: only resolve session on root session idle, not subagent idle#601kilo-code-bot[bot] wants to merge 1 commit intomainfrom
Conversation
The onSessionStatusChanged callback was resolving the session as done when any session.status → idle event arrived, without checking which session went idle. When a subagent (e.g. Explore Agent) finished, its idle event would prematurely resolve the parent session, returning a partial result. Pass sessionID through the onSessionStatusChanged callback and compare against the root session ID before resolving in run-session.ts.
| }, | ||
|
|
||
| onSessionStatusChanged: status => { | ||
| onSessionStatusChanged: (status, _eventSessionId) => { |
There was a problem hiding this comment.
WARNING: Session status from child sessions can still prematurely end root streaming
This callback ignores eventSessionId and treats any idle as stream completion. The same subagent/child-session behavior called out in run-session.ts applies here too, so a child idle can flip isStreaming to false and fire onStreamComplete before the root session is actually done.
| }, | ||
|
|
||
| onSessionStatusChanged: status => { | ||
| onSessionStatusChanged: (status, _eventSessionId) => { |
There was a problem hiding this comment.
WARNING: idle from non-root sessions can mark UI streaming complete too early
eventSessionId is ignored, so any session status event (including child/subagent sessions) drives setIsStreaming and onComplete. This can cause premature completion state and UI transitions while the primary session is still running.
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Fix these issues in Kilo Cloud Overview
Issue Details (click to expand)CRITICAL
WARNING
SUGGESTION
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments:
Files Reviewed (6 files)
|
Summary
onSessionStatusChangedinrun-session.tsresolved the session as "done" when anysession.status → idleevent arrived, without checking which session went idle. When a subagent (e.g. Explore Agent) finished, its child session idle event prematurely resolved the parent orchestrator session, returning a partial result.sessionIDparameter to theonSessionStatusChangedcallback throughout the event processor pipeline, and inrun-session.tsthe idle handler now compares the event's session ID against the root session ID before resolving. Child/subagent idle events are ignored.useCloudAgentStream, app-builderstreaming.ts) and tests for the new callback signature.Changed files
src/lib/cloud-agent-next/processor/types.tssessionIDparam toonSessionStatusChangedcallback typesrc/lib/cloud-agent-next/processor/event-processor.tssessionIDfrom event data to callbacksrc/lib/cloud-agent-next/run-session.tseventSessionId === sessionIdbefore resolving on idlesrc/components/cloud-agent-next/useCloudAgentStream.ts_eventSessionIdparamsrc/components/app-builder/project-manager/sessions/v2/streaming.ts_eventSessionIdparamsrc/lib/cloud-agent-next/processor/event-processor.test.tssessionIDBuilt for Remon Oldenbeuving by Kilo for Slack