Skip to content

fix(cloud-agent): keep busy cloud sessions in the active list without an open run - #8523

Merged
iscekic merged 2 commits into
mainfrom
fix/active-cloud-sessions
Oct 22, 2026
Merged

iscekic merged 2 commits into
mainfrom
fix/active-cloud-sessions

Conversation

@iscekic

@iscekic iscekic commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Problem

Active now — the mobile Home live section and the Agents tab — can say "nothing is running" while a cloud agent works.

Cause

activeSessions.list treated two things as proof that a cloud session is live:

  • an open cloud_agent_session_runs row, or
  • a warm idle status inside the recency window.

A cloud session between message turns keeps a non-idle status with no open run. Both proofs then fail while the session is still active: session-ingest keeps recording activity, but nothing read it. The row came back only after the session went idle, so finished sessions appeared for a short time and running ones never did.

Change

last_activity_at is now the third proof of life, inside the same recency window. The candidate keeps its stored status, so question and permission rows still report needs-input.

Verification

  • New router tests: a busy turn with fresh activity is included, an attention row with fresh activity keeps its status, and stale busy activity stays excluded.
  • The existing warm-idle, open-run, run-open-wins, and stale-idle cases still pass.
  • The affected Jest suites pass on a disposable VM against Postgres.
  • A read-only production check showed live cloud sessions with no open run that the old predicate dropped and the new one keeps.

… an open run

Active now treated an open cloud run or a warm idle status as the only proofs of life. A cloud session between message turns keeps a non-idle status with no open run. The list then dropped a session that was still working. The same session reappeared only after it went idle, inside the warm window.

Recorded session activity is now the third proof of life, inside the same recency window. The candidate carries its stored status, so a question or permission row still reports needs-input.
@iscekic iscekic self-assigned this Oct 22, 2026
@kilo-code-bot

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

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The incremental change is a one-line, correct test-harness fix: the rendered cloud-candidate query now interpolates CLOUD_AGENT_LIVE_CUTOFF twice (active-sessions-list.ts lines 575 and 577), so replaceAll correctly rewrites both Postgres cutoffs into the SQLite literal instead of leaving Postgres syntax in the prepared statement.

Assumptions: [INFERENCE] The string now() - interval '15 minutes' must match Drizzle's rendering exactly for either .replace or .replaceAll to work; that match is unchanged from the previously reviewed behavior, so no new risk is introduced. Runtime execution of the affected suite was not performed (read-only review).

Files Reviewed (3 files)

  • services/cloud-agent-next/src/telemetry/report-consumer.glanceable.test.ts - incremental change, no issues
  • apps/web/src/lib/active-sessions-list.ts - re-verified liveness predicate still matches the harness rewrite
  • apps/web/src/routers/active-sessions-router.cloud.test.ts - unchanged since previous review
Previous Review Summary (commit eacabae)

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

Previous review (commit eacabae)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The new last_activity_at liveness branch in listActiveSessions is correctly scoped (cloud-agent rows only, same 15-minute window, org and parent filters preserved), and the added router tests cover busy, attention, and stale-activity cases with no regressions to the existing run-open and warm-idle paths.

Assumptions: [INFERENCE] Two edges are not exercised by the added tests and were not verifiable from this diff alone: (1) an attention (question/permission) row that has no open run is now admitted only while last_activity_at is within the window, so it would drop out of the active set after ~15 minutes of user inaction — acceptable only if such rows always carry an open run in production, which the run lifecycle was not read to confirm; (2) a stored non-attention idle/null status admitted solely by fresh activity is still reported as idle/empty because resolveCloudCandidateStatus only upgrades on run_open, so such a row appears in the list but may not render as running. Neither is proven harmful from the changed lines.

Files Reviewed (2 files)
  • apps/web/src/lib/active-sessions-list.ts
  • apps/web/src/routers/active-sessions-router.cloud.test.ts

Fix these issues in Kilo Cloud


Reviewed by deepseek-flash-latest · Input: 47.9K · Output: 3K · Cached: 278.7K

Review guidance: REVIEW.md from base branch main

The glanceable harness rewrites the Postgres recency cutoff into a SQLite literal. The list query now carries the cutoff twice, so a single replacement left Postgres syntax in the statement. Replace every occurrence.
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