Skip to content

fix: only resolve run-session when root session goes idle, not subagent sessions#600

Closed
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
fix/run-session-subagent-idle-resolution
Closed

fix: only resolve run-session when root session goes idle, not subagent sessions#600
kilo-code-bot[bot] wants to merge 1 commit intomainfrom
fix/run-session-subagent-idle-resolution

Conversation

@kilo-code-bot
Copy link
Contributor

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

Summary

  • Bug: runSessionToCompletion in run-session.ts resolved prematurely when a subagent (child session) went idle, returning the subagent's partial result instead of waiting for the root session to complete.
  • Fix: Pass sessionID through the onSessionStatusChanged callback so consumers can identify which session changed status, and gate resolution in run-session.ts on the root session's idle event only.

Changes

  1. src/lib/cloud-agent-next/processor/types.ts: Added sessionId parameter to onSessionStatusChanged callback signature.
  2. src/lib/cloud-agent-next/processor/event-processor.ts: Destructure sessionID from the event data and pass it to the callback.
  3. src/lib/cloud-agent-next/run-session.ts: Check that the idle event's sessionId matches the root cloudAgentSessionId before resolving.
  4. src/components/cloud-agent-next/useCloudAgentStream.ts: Accept the new _sessionId parameter (unused).
  5. src/components/app-builder/project-manager/sessions/v2/streaming.ts: Accept the new _sessionId parameter (unused).

Built for Remon Oldenbeuving by Kilo for Slack

…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) => {
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 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) => {
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: 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.

@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)

WARNING

File Line Issue
src/components/app-builder/project-manager/sessions/v2/streaming.ts 183 Idle status from child sessions can prematurely end root streaming.
src/components/cloud-agent-next/useCloudAgentStream.ts 242 Stream completion can be triggered by non-root session idle events.
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
src/lib/cloud-agent-next/processor/event-processor.test.ts 444 Existing expectations for onSessionStatusChanged appear to assert a single argument and may need updates now that a sessionId argument is passed.
src/lib/cloud-agent-next/processor/event-processor.test.ts 471 Existing expectations for onSessionStatusChanged appear to assert a single argument and may need updates now that a sessionId argument is passed.
Files Reviewed (5 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.ts - 0 issues
  • src/lib/cloud-agent-next/processor/types.ts - 0 issues
  • src/lib/cloud-agent-next/run-session.ts - 0 issues

@RSO RSO requested a review from eshurakov February 26, 2026 09:26
@RSO RSO closed this Feb 26, 2026
@RSO
Copy link
Contributor

RSO commented Feb 26, 2026

Superseded by #603

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.

1 participant