Skip to content

fix(cloud-agent-sdk): stop dropping entity-upsert stream events - #5081

Merged
eshurakov merged 2 commits into
mainfrom
session/agent_0df890df-8d82-4753-ac16-9da4993c1373
Aug 6, 2026
Merged

fix(cloud-agent-sdk): stop dropping entity-upsert stream events#5081
eshurakov merged 2 commits into
mainfrom
session/agent_0df890df-8d82-4753-ac16-9da4993c1373

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

Summary

Live cloud-agent tool cards were stuck on spinners (bash...) until page reload. Root cause: PR #4987 added client-side filtering that dropped stream frames with eventId <= lastEventId.

The Durable Object entity-upserts tool/message parts under a stable SQLite row id and rebroadcasts that same (or older) eventId with a newer payload (pendingrunningcompleted). Filtering by id dropped those live updates; REST history on reload still had the final state, so reload looked fine.

This removes the client-side eventId drop entirely. lastEventId remains only as a high-water mark for reconnect fromId. Exclusive DO fromId (id > fromId) already handles replay catch-up.

Test plan

  • pnpm test -- cloud-agent-transport.test.ts in packages/cloud-agent-sdk (42 passed)
  • Live cloud agent session: run parallel bash tools and confirm cards leave the spinner and show command/output without reload
  • Reconnect mid-session and confirm stream still advances via fromId

eshurakov and others added 2 commits August 6, 2026 08:37
Change the duplicate event filtering logic to allow events with an
eventId equal to the current cursor.

Previously, events with `eventId <= lastEventId` were dropped. This
caused issues with entity upserts (e.g., tool part updates) where the
system re-emits the same eventId with a new payload (e.g., transitioning
from `pending` to `completed`). By changing the check to `raw.eventId <
lastEventId`, we ensure that live tool updates and message updates are
correctly delivered while still dropping strictly older replayed events.

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Stop dropping events with an `eventId` less than or equal to the
`lastEventId`. The Durable Object (DO) performs entity upserts for
tool parts and messages using a stable row ID, which can result in
rebroadcasting the same `eventId` with updated payloads (e.g.,
transitioning from `pending` to `completed`).

Previously, the transport dropped these events, causing live tools
to remain stuck with empty or stale input. The `lastEventId` now
only tracks the high-water mark for reconnection purposes.

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Comment thread packages/cloud-agent-sdk/src/cloud-agent-transport.test.ts
@kilo-code-bot

kilo-code-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: 1 Issue Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1

The core fix is sound: removing client-side eventId filtering restores live entity-upsert rebroadcasts (tool cards leaving the spinner), and lastEventId is correctly kept as a monotonic high-water mark for reconnect fromId. I verified that every positive-id event type affected by the new at-least-once delivery (message.updated, message.part.updated, message.part.removed, session.*, complete/interrupted/error, autocommit_*) maps to idempotent sink handlers (upsert/delete/state transitions), and that non-idempotent message.part.delta events are broadcast-only with eventId: 0, so they were never subject to the removed filter. Tests were updated consistently with the new semantics.

Issue Details (click to expand)

SUGGESTION

File Line Issue
packages/cloud-agent-sdk/src/cloud-agent-transport.test.ts 1296 Stale section banner // Exactly-once event replay contradicts the renamed describe block and the new at-least-once assertions
Files Reviewed (2 files)
  • packages/cloud-agent-sdk/src/cloud-agent-transport.ts - 0 issues
  • packages/cloud-agent-sdk/src/cloud-agent-transport.test.ts - 1 issue

Fix these issues in Kilo Cloud


Reviewed by kimi-k3 · Input: 80.1K · Output: 20.3K · Cached: 1.5M

Review guidance: REVIEW.md from base branch main

@eshurakov
eshurakov merged commit 651162c into main Aug 6, 2026
23 checks passed
@eshurakov
eshurakov deleted the session/agent_0df890df-8d82-4753-ac16-9da4993c1373 branch August 6, 2026 09:07
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