fix(cloud-agent-sdk): stop dropping entity-upsert stream events - #5081
Conversation
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>
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
The core fix is sound: removing client-side Issue Details (click to expand)SUGGESTION
Files Reviewed (2 files)
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 |
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 witheventId <= lastEventId.The Durable Object entity-upserts tool/message parts under a stable SQLite row id and rebroadcasts that same (or older)
eventIdwith a newer payload (pending→running→completed). 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.
lastEventIdremains only as a high-water mark for reconnectfromId. Exclusive DOfromId(id > fromId) already handles replay catch-up.Test plan
pnpm test -- cloud-agent-transport.test.tsinpackages/cloud-agent-sdk(42 passed)fromId