Skip to content

fix(cloud-agent-next): scrub transient lifecycle parts on session restore - #5092

Merged
eshurakov merged 2 commits into
mainfrom
eshurakov/serene-monsoon
Aug 6, 2026
Merged

fix(cloud-agent-next): scrub transient lifecycle parts on session restore#5092
eshurakov merged 2 commits into
mainfrom
eshurakov/serene-monsoon

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

Summary

  • Before kilo import, strip message parts with metadata["kilocode.lifecycle"] == "transient" from the session export (same pre-import sanitize path as negative token counts).
  • Prevents cold-restore failures where leftover CLI snapshot-progress UI parts are copied into AI SDK providerOptions and rejected (providerOptions.kilocode.lifecycle expected record, got "transient").
  • Does not fix warm workspaces that skip re-import; a CLI-side strip in toModelMessages is still needed for full coverage.

Test plan

  • bun test src/restore-session.test.ts in services/cloud-agent-next/wrapper (40 pass), including new test that captures the import payload and asserts transient parts are removed
  • After sandbox image/wrapper deploy: restore a session whose export contains a leftover Initializing snapshot… transient part; confirm follow-up prompts succeed

…tore

Drop leftover CLI snapshot-progress parts (kilocode.lifecycle=transient)
from export JSON before kilo import so cold restore cannot poison later
LLM turns via invalid providerOptions.
Comment thread services/cloud-agent-next/wrapper/src/restore-session.ts Outdated
Comment thread services/cloud-agent-next/wrapper/src/restore-session.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental review of the sanitize-pipeline rework (one composed jq pass with a now-total transient-parts filter) found no issues in the changed code; both previous findings are resolved at HEAD and covered by a new regression test.

Files Reviewed (2 files)
  • services/cloud-agent-next/wrapper/src/restore-session.ts
  • services/cloud-agent-next/wrapper/src/restore-session.test.ts
Previous Review Summary (commit f133b2f)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit f133b2f)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
services/cloud-agent-next/wrapper/src/restore-session.ts 54 Transient-parts jq filter is non-total: non-object top-level JSON yields empty output with exit 0, silently truncating a user-supplied --file snapshot to 0 bytes before kilo import

SUGGESTION

File Line Issue
services/cloud-agent-next/wrapper/src/restore-session.ts 674 Two sequential jq passes each read+rewrite the full snapshot; combining both filters into one invocation halves I/O on large exports
Files Reviewed (2 files)
  • services/cloud-agent-next/wrapper/src/restore-session.ts - 2 issues
  • services/cloud-agent-next/wrapper/src/restore-session.test.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by kimi-k3 · Input: 41K · Output: 8.7K · Cached: 245.9K

Review guidance: REVIEW.md from base branch main

- Guard the transient-parts jq filter with a top-level type check so
  non-object snapshots pass through unchanged instead of yielding empty
  output that sanitizeSnapshotWithJq would rename (0 bytes) over a
  user-supplied --file snapshot
- Compose token-count and transient-part sanitization into one jq
  invocation so large exports are read+rewritten once per restore
- Fix the part-shape typing in the transient-parts test and add a
  regression test for non-object --file passthrough
@eshurakov
eshurakov merged commit 70787a5 into main Aug 6, 2026
16 checks passed
@eshurakov
eshurakov deleted the eshurakov/serene-monsoon branch August 6, 2026 13:28
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