refactor(cloud-agent-next): make wrapper the single control plane#1118
Merged
refactor(cloud-agent-next): make wrapper the single control plane#1118
Conversation
Contributor
Code Review SummaryStatus: 1 Issues Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)WARNING
Other Observations (not in diff)N/A Files Reviewed (18 files)
Reviewed by gpt-5.4-20260305 · 3,053,710 tokens |
- Replace rawRequest with v2 SDK and add event subscription generation counter - Forward variant to SDK, fail on missing session - Remove unsafe casts, narrow deps, and add crash handlers - Suppress prefer-const lint for late-bound lifecycleManager - Remove unnecessary type assertion in client test - Address PR review warnings
… subscription leaks Cancel old SDK event subscriptions immediately by propagating the AbortController's signal to event.subscribe(). Previously, aborting only set a boolean flag that was checked on the next iteration of the for-await loop, leaving the underlying HTTP stream alive until the next SSE event arrived. Now close() and reconnectEventSubscription() tear down the stream transport instantly.
9713dc1 to
1bc69bc
Compare
Call callbacks.onSseEvent() when server.connected arrives, matching the pattern used by server.heartbeat and regular kilocode events. This starts the 15-second dead-subscription recovery timer immediately upon SSE subscription instead of waiting 10-30s for the first heartbeat.
jeanduplessis
approved these changes
Mar 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactor cloud-agent-next so the wrapper process becomes the single control plane inside the sandbox container. Instead of the DO/Worker managing two separate processes (kilo server + wrapper), the wrapper starts and owns the kilo server in-process via
@kilocode/sdk'screateKilo(). This eliminates split-lifetime bugs, simplifies lifecycle management, and reduces the DO's knowledge of container internals.Architectural changes:
createKilo(), replacing the DO-managedserver-manager. The DO now manages only one process (the wrapper).--agent-session,--user-id,--session-id) is now passed via CLI args at wrapper startup. Per-execution config (autoCommit, model, etc.) is passed viaPOST /job/promptbody.WRAPPER_VERSION); mismatched wrappers are restarted.Deleted modules (net −1159 lines):
server-manager.ts,kilo-types.ts,sse-consumer.ts,kilo-client.ts— replaced bykilo-api.ts,ports.ts,wrapper-version.ts.Frontend fix: Fixed a streaming regression where message text disappeared after completion. Completed messages now stay buffered for late metadata/part updates.
Verification
pnpm typecheck— passes (tsgo + wrapper tsc)Visual Changes
N/A
Reviewer Notes
createKilo()SDK call inwrapper/src/main.tsis the central architectural change — start review there.kilo-api.tsis the new adapter between wrapper modules and the@kilocode/sdkclient; methods the SDK doesn't expose typed methods for (commit-message, permission reply) use raw fetch against the in-process server URL.maxRuntimeMsis never sent by the frontend today — always defaults to 30 min.server.heartbeatevery 10s on SSE; the wrapper now forwards it to the DO. DO ingest heartbeat debounce is 30s; stale threshold is 90s (~3 missed heartbeats).