Skip to content

Cloud Agent - Filter child session events in event processor#603

Merged
eshurakov merged 1 commit intomainfrom
eshurakov/cloud-agent-event-processor-sessions
Feb 26, 2026
Merged

Cloud Agent - Filter child session events in event processor#603
eshurakov merged 1 commit intomainfrom
eshurakov/cloud-agent-event-processor-sessions

Conversation

@eshurakov
Copy link
Contributor

Summary

  • Filter child/sub-agent session events in event-processor.ts so that onSessionStatusChanged, onStreamingChanged, and the streaming flag are only toggled by root session events.
  • Prevents consumers (e.g. Slack bot via run-session.ts) from prematurely disconnecting when a child session emits idle while the parent session is still running.
  • Child sessions still get user message completion and onError callbacks — only status/streaming propagation is suppressed.

Changes

event-processor.ts

  • Added isChildSession() helper using the existing sessionParents map
  • handleSessionStatus: skips onSessionStatusChanged/onStreamingChanged for child sessions
  • handleSessionIdle: accepts { sessionID } param; skips streaming toggle for child sessions
  • handleSessionError: skips streaming toggle for child sessions; onError still fires for all
  • handleSessionTurnClose: passes skipStreamingToggle to forceCompleteAllMessages for child sessions
  • forceCompleteAllMessages: accepts optional skipStreamingToggle parameter

event-processor.test.ts

  • Added 5 test cases in a child session event filtering describe block covering all filtering scenarios

Skip onSessionStatusChanged, onStreamingChanged, and streaming flag
toggling for child/sub-agent sessions. This prevents consumers like
the Slack bot from prematurely disconnecting when a child session
emits idle while the parent session is still running.

Child sessions still get user message completion and onError callbacks.
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Feb 26, 2026

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
src/lib/cloud-agent-next/processor/event-processor.ts 512 Unsafe cast in session.idle dispatch (data as { sessionID: string }) can pass undefined session IDs at runtime, causing child/root classification and streaming behavior to silently default to root handling. Add runtime validation before calling handleSessionIdle.
Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

None.

Files Reviewed (2 files)
  • src/lib/cloud-agent-next/processor/event-processor.ts - 1 issue
  • src/lib/cloud-agent-next/processor/event-processor.test.ts - 0 issues

Fix these issues in Kilo Cloud

@eshurakov eshurakov merged commit 57762c6 into main Feb 26, 2026
12 checks passed
@eshurakov eshurakov deleted the eshurakov/cloud-agent-event-processor-sessions branch February 26, 2026 10:02
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.

2 participants