Skip to content

feat(cloud-agent-next): supervise native Kilo execution independently of Cloud turns - #7256

Merged
eshurakov merged 3 commits into
mainfrom
eshurakov/calm-coyote
Oct 7, 2026
Merged

eshurakov merged 3 commits into
mainfrom
eshurakov/calm-coyote

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

Summary

workspace_* execution is now supervised by per-process native session
supervisors instead of deriving activity and deadlines from accepted Cloud
messages. The sandbox stays alive while any Kilo session needs compute,
regardless of which chat the user views or whether Cloud Agent submitted the
current work, and a stuck native execution is interrupted with a specific
reason.

What changed

  • Native supervision (session-supervisor.ts, runtime-activity.ts,
    session-snapshot.ts): observe every session before route filtering,
    including unrouted sessions, subagents and autonomous continuations.
    Reconcile the global feed with a bounded initial snapshot, single-flight on
    reconnect and every 30 s, fencing newer stream observations.
  • Deadline policy: workspace_* no-progress moves from 7 to 20 minutes and
    applies to silent running tools too (user waits pause only that clock). The
    separate 120-minute wall-clock cap remains. The supervisor aborts the
    affected tree once, settles accepted messages with no_progress /
    execution_limit, and uses bounded runtime recovery when cancellation is
    unconfirmed.
  • Lifecycle fixes: reconcile deferred completed-message close evidence
    fenced by native runtime/execution and Cloud lastMessageId, and preserve
    undispatched attachment materialization across runtime replacement while
    retaining Stop and deadline cancellation.
  • Docs/spec: update docs/control-plane.md, AGENTS.md,
    .specs/cloud-agent-session.md and the E2E README; add wrapper, unit and E2E
    coverage.

Verification

  • wrapper: tsgo --noEmit clean; bun test src -> 970 pass, 16 skip, 0 fail.
  • cloud-agent-next: tsgo --noEmit clean; vitest run test/unit -> 1096 pass.
  • oxlint -> 0 warnings, 0 errors.
  • Not run: full real-Kilo/local-stack E2E. The .real.test.ts contracts need a
    pinned Kilo CLI and are skipped in the default wrapper run. format:check
    reports 4 pre-existing drizzle snapshot JSONs untouched by this change.

… of Cloud turns

Own Kilo execution activity and deadlines in per-process native session
supervisors instead of deriving them from accepted Cloud messages.

- Add session-supervisor, runtime-activity and session-snapshot: observe
  every session before route filtering, including unrouted, subagent and
  autonomous continuations; reconcile the global feed with a bounded
  snapshot and fence newer stream observations.
- Change workspace_* no-progress to 20 minutes including silent running
  tools (user waits pause only that clock) and keep the separate
  120-minute execution cap; abort the affected tree and settle accepted
  messages once, with bounded runtime recovery when cancellation is
  unconfirmed.
- Reconcile deferred completed-message close evidence fenced by native
  runtime/execution and Cloud lastMessageId, and preserve attachment
  materialization across runtime replacement while retaining Stop and
  deadline cancellation.
- Update the control-plane doc, cloud-agent AGENTS.md, and the session
  spec; extend wrapper, unit and E2E test coverage.
@kilo-code-bot

kilo-code-bot Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

All seven prior findings are resolved in the incremental range: snapshot-only sessions now start at revision: -1 (session-supervisor.ts:108), the tombstone fence uses >= (session-supervisor.ts:418), reconcile routes through the capped remember helper (session-supervisor.ts:446), the restart-cancelled dispatch is swallowed via isCancelledBy (turn.ts:151), the evidence mkdir creates its parent (supervision-local.ts:65), the header assertion reads x-kilo-directory (kilo-api.test.ts:162), and DEBUG.md now documents the 20-minute clock. No new correctness, security, or memory-leak issues were found in the changed lines.

Files Reviewed (10 files)
  • services/cloud-agent-next/DEBUG.md
  • services/cloud-agent-next/test/e2e/supervision-local.ts
  • services/cloud-agent-next/wrapper/src/control-plane/kilo-activity-fixture.ts
  • services/cloud-agent-next/wrapper/src/control-plane/kilo-activity.real.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/kilo-supervision-fixture.real.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/session-supervisor.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/session-supervisor.ts
  • services/cloud-agent-next/wrapper/src/control-plane/turn.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/turn.ts
  • services/cloud-agent-next/wrapper/src/kilo-api.test.ts
Previous Review Summary (commit 96b93a9)

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

Previous review (commit 96b93a9)

Status: 7 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
services/cloud-agent-next/wrapper/src/control-plane/session-supervisor.ts 404 Snapshot-only (unrouted/subagent) sessions can be skipped whenever any concurrent session emits a feed event, because session() stamps a new record with the current global revision; under continuous activity their deadlines never start.
services/cloud-agent-next/wrapper/src/control-plane/session-supervisor.ts 137 finish() writes its tombstone at the current revision without incrementing it, but the snapshot fence uses strict >; a cancelled execution can be resurrected by an in-flight snapshot.
services/cloud-agent-next/wrapper/src/control-plane/session-supervisor.ts 426 reconcile adds message roles without the MAX_MESSAGE_ROLES cap, so observedSessions() emits unbounded messageIds and each 30 s snapshot performs ever more sequential getSessionMessage reads until it times out.
services/cloud-agent-next/wrapper/src/control-plane/turn.ts 1007 Aborting an in-flight dispatched prompt on restart rejects with AbortError, which is not treated as a retired/unreachable success, so the resubmitted turn is instead failed prompt_failed.
services/cloud-agent-next/test/e2e/supervision-local.ts 65 Non-recursive mkdir makes the documented acceptance command fail with ENOENT because the parent evidence directory is never created.

SUGGESTION

File Line Issue
services/cloud-agent-next/wrapper/src/kilo-api.test.ts 181 Header assertion reads x-opencode-directory while the SDK emits x-kilo-directory, making expect(header).toBeNull() tautological.
services/cloud-agent-next/src/shared/control-plane-timers.ts 105 noProgressMs moved from 7 to 20 minutes but DEBUG.md:181 still documents a seven-minute no-progress clock.
Files Reviewed (40 files)
  • .specs/cloud-agent-session.md
  • services/cloud-agent-next/AGENTS.md
  • services/cloud-agent-next/docs/control-plane.md
  • services/cloud-agent-next/package.json
  • services/cloud-agent-next/src/shared/control-plane-timers.ts - 1 issue
  • services/cloud-agent-next/test/e2e/README.md
  • services/cloud-agent-next/test/e2e/auth.ts
  • services/cloud-agent-next/test/e2e/client.ts
  • services/cloud-agent-next/test/e2e/fake-llm-core.ts
  • services/cloud-agent-next/test/e2e/fake-llm-supervision.ts
  • services/cloud-agent-next/test/e2e/scenarios-shared-process-faults.ts
  • services/cloud-agent-next/test/e2e/supervision-local.ts - 1 issue
  • services/cloud-agent-next/test/integration/control-plane-session-v2-interactions.test.ts
  • services/cloud-agent-next/test/unit/e2e/client.test.ts
  • services/cloud-agent-next/test/unit/e2e/fake-llm-supervision.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/kilo-activity-fixture.ts
  • services/cloud-agent-next/wrapper/src/control-plane/kilo-activity.real.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/kilo-event-feed.ts
  • services/cloud-agent-next/wrapper/src/control-plane/kilo-health-diagnostic.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/kilo-runtime.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/kilo-runtime.ts
  • services/cloud-agent-next/wrapper/src/control-plane/kilo-supervision-fixture.real.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/main.ts
  • services/cloud-agent-next/wrapper/src/control-plane/runtime-activity.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/runtime-activity.ts
  • services/cloud-agent-next/wrapper/src/control-plane/session-host.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/session-snapshot.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/session-snapshot.ts
  • services/cloud-agent-next/wrapper/src/control-plane/session-supervisor.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/session-supervisor.ts - 3 issues
  • services/cloud-agent-next/wrapper/src/control-plane/terminals.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/turn.test.ts
  • services/cloud-agent-next/wrapper/src/control-plane/turn.ts - 1 issue
  • services/cloud-agent-next/wrapper/src/kilo-api.test.ts - 1 issue
  • services/cloud-agent-next/wrapper/src/kilo-api.ts

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash · Input: 66.5K · Output: 22.2K · Cached: 1.2M

Review guidance: REVIEW.md from base branch main

…rvision

- Apply snapshot-only sessions even when other sessions emit events during
  the read, and keep a busy pre-cancellation snapshot from resurrecting a
  cancelled execution.
- Cap message roles on the reconcile path and re-read only in-flight
  assistant messages in snapshots.
- Do not fail a resubmitted turn with prompt_failed when a runtime restart
  cancels its retired in-flight dispatch.
- Create the E2E evidence parent directory recursively, read the
  x-kilo-directory header in the SDK boundary test, and update the
  no_progress guidance in DEBUG.md.
- Merge overlapping turn and session supervisor cases without dropping
  assertions.
- Reduce the pinned real-Kilo contracts from 11 to 9: drop retry-as-busy
  and merge the two child permission contracts.
- Remove unused evidence capture from the real-Kilo activity fixture.
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