CloudAgentNext - Move cli_sessions_v2 creation to session-ingest RPC#242
CloudAgentNext - Move cli_sessions_v2 creation to session-ingest RPC#242
Conversation
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Fix these issues in Kilo Cloud Overview
Issue Details (click to expand)WARNING
Files Reviewed (25 files)
|
Replace backend tRPC calls (createV2, linkCloudAgent, delete) with direct session-ingest WorkerEntrypoint RPC methods (createSessionForCloudAgent, deleteSessionForCloudAgent). This removes the roundtrip through the Next.js backend for session record management and moves the DB write closer to the worker that owns the table. - Convert session-ingest from plain Hono export to WorkerEntrypoint class - Add createSessionForCloudAgent / deleteSessionForCloudAgent RPC methods - Add SessionIngestBinding type declarations for both workers - Remove linkKiloSessionInBackend from DO, session-service, and ingest handler - Remove cli_sessions_v2 inserts from Next.js routers - Add rollback logic in session-prepare when DO prepare() fails - Upgrade cloudflare-session-ingest vitest to v3.2.4 - Add created_on_platform to session-ingest RPC
7a5b531 to
ff70997
Compare
| throw new Error('Cannot link session: KILOCODE_BACKEND_BASE_URL not configured'); | ||
| } | ||
|
|
||
| const response = await fetch(`${backendUrl}/api/cloud-sessions/linkSessions`, { |
There was a problem hiding this comment.
this endpoint doesn't even exist :-)
Replace session-ingest-binding.d.ts files with regular .ts files that use explicit exports/imports, consistent with the rest of the codebase.
Extract RPC methods into SessionIngestRPC WorkerEntrypoint class in its own file, reverting index.ts to export default app. Consumers reference the named entrypoint via wrangler.jsonc service binding config. Also adds try/catch + logging around RPC calls in session-service.ts.
There was a problem hiding this comment.
I wonder if we could extract some functions for reuse 🤔
There was a problem hiding this comment.
definitely, can do a service layer
| throw new Error( | ||
| `Session ${sessionId} has no kiloSessionId in metadata. Cannot restore snapshot.` | ||
| ); | ||
| } |
There was a problem hiding this comment.
[WARNING]: Cold-start resume now hard-fails for sessions without kiloSessionId in DO metadata
Pre-existing sessions that were created before kiloSessionId was persisted in metadata will fail to cold-start resume with this error. Previously, restoreSessionSnapshot used the authToken to call the HTTP export API, so it didn't need kiloSessionId in metadata.
Is there a migration path for these sessions, or is this an acceptable breaking change? If sessions are short-lived enough that no pre-existing ones will attempt cold-start resume, this is fine — but worth confirming.
Summary
Update Cloud Agent Next to use the Ingest Service to pre-create CLI sessions and add a link between Cloud Agent Session and CLI session.