Skip to content

fix: only resolve session on root session idle, not subagent idle#601

Open
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
fix/subagent-idle-premature-resolve
Open

fix: only resolve session on root session idle, not subagent idle#601
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
fix/subagent-idle-premature-resolve

Conversation

@kilo-code-bot
Copy link
Contributor

@kilo-code-bot kilo-code-bot bot commented Feb 26, 2026

Summary

  • Bug: onSessionStatusChanged in run-session.ts resolved 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 child session idle event prematurely resolved the parent orchestrator session, returning a partial result.
  • Fix: Added sessionID parameter to the onSessionStatusChanged callback throughout the event processor pipeline, and in run-session.ts the idle handler now compares the event's session ID against the root session ID before resolving. Child/subagent idle events are ignored.
  • Updated all consumers (useCloudAgentStream, app-builder streaming.ts) and tests for the new callback signature.

Changed files

File Change
src/lib/cloud-agent-next/processor/types.ts Added sessionID param to onSessionStatusChanged callback type
src/lib/cloud-agent-next/processor/event-processor.ts Pass sessionID from event data to callback
src/lib/cloud-agent-next/run-session.ts Check eventSessionId === sessionId before resolving on idle
src/components/cloud-agent-next/useCloudAgentStream.ts Accept new _eventSessionId param
src/components/app-builder/project-manager/sessions/v2/streaming.ts Accept new _eventSessionId param
src/lib/cloud-agent-next/processor/event-processor.test.ts Updated assertions to include sessionID

Built for Remon Oldenbeuving by Kilo for Slack

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) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kilo-code-bot
Copy link
Contributor Author

kilo-code-bot bot commented Feb 26, 2026

Code Review Summary

Status: 2 Issues Found | Recommendation: Address before merge

Fix these issues in Kilo Cloud

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

CRITICAL

File Line Issue

WARNING

File Line Issue
src/components/app-builder/project-manager/sessions/v2/streaming.ts 183 onSessionStatusChanged ignores eventSessionId, so child-session idle can set isStreaming false and call onStreamComplete before the root session is complete.
src/components/cloud-agent-next/useCloudAgentStream.ts 242 onSessionStatusChanged ignores eventSessionId, allowing child-session status events to drive root streaming completion (setIsStreaming(false)/onComplete).

SUGGESTION

File Line Issue
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
None N/A No additional issues found outside the diff.
Files Reviewed (6 files)
  • src/components/app-builder/project-manager/sessions/v2/streaming.ts - 1 issue
  • src/components/cloud-agent-next/useCloudAgentStream.ts - 1 issue
  • src/lib/cloud-agent-next/processor/event-processor.test.ts - 0 issues
  • src/lib/cloud-agent-next/processor/event-processor.ts - 0 issues
  • src/lib/cloud-agent-next/processor/types.ts - 0 issues
  • src/lib/cloud-agent-next/run-session.ts - 0 issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants