Skip to content

cua serve stops an idle vendor runtime and relaunches it on the next call #107

Closed

Description

@SSFSKIM

Purpose

Follow-up to #105 (plugin 0.8.0: the vendor runtime launches on the first js). A runtime that was launched stays for the life of the connection, so a session that used cua once at the start of a day keeps its stack (cua_node ×2, node_repl ×2, codex sandbox, app-server) for the day. The owner (2026-10-10) wants an idle shutdown: after no tool call for a while, cua serve stops the runtime it launched; the next call that needs one relaunches it.

Behaviour:

  • Idle = no tool call (js, js_reset, end_task, profiles_list's live part) for CUA_RUNTIME_IDLE_MS (default 15 minutes; 0 disables). The timer arms when a call completes and is cleared by the next call; a call still running never counts as idle.
  • On idle: stop the runtime through the same path end_task/connection close use for the vendor processes (no leftover in run/, attachments detached so MAWS and Chrome leases release as on a normal end), keep the MCP connection and the MAWS socket dial, log one diagnostics line (runtime stopped after N min idle).
  • On the next js/js_reset after an idle stop: relaunch (the lazy path from cua serve launches the vendor runtime lazily, on the first call that needs it #105) and tell the model, in that call's result, that the runtime restarted after idling and its REPL state (variables, app handles, tabs) is gone, so it must rebind; the first-call API document is returned as on any fresh runtime. end_task after an idle stop with no task open answers as today's no-task end_task.
  • The handshake record, secrets_list, devices_* and the registry part of profiles_list are untouched. The HTTP agent's sessions get the same timer.
  • No change to the vendor runtime (D-1-like: unmodified).

Verify: unit tests with a counting prepareLaunch double and a fake clock: the timer arms only after a completed call; a call during the window resets it; the stop runs the normal cleanup; the relaunch counts one launch and the result carries the restart notice; 0 disables; a call racing the stop (arrives during teardown) waits and gets a fresh runtime, never an error from the dying one. HOME=<scratch> npm test, npm run test:mods, claude plugin validate . green. README: the footprint note gains the idle rule and the env variable. Plugin 0.8.0 → 0.9.0. Repository SSFSKIM/cua, branch off main in a worktree; no attribution footers.

Activity

  1. added
    enhancement
    status:ready-for-implementer
    priority:P3
    status:in-progress
    and removed
    status:ready-for-implementer
    on Oct 10, 2026
  2. SSFSKIM commented on Oct 10, 2026

    @SSFSKIM
    OwnerAuthor

    [board] in-progress: Worker dispatched (opus) in cua worktree cua-wt-idle on branch feat/idle-runtime.

  3. removed
    status:in-progress
    on Oct 10, 2026
  4. SSFSKIM commented on Oct 10, 2026

    @SSFSKIM
    OwnerAuthor

    [board] done: PR #108 merged at 3fceddd (plugin 0.9.0). A launched runtime stops after CUA_RUNTIME_IDLE_MS (default 15 min, 0 disables, max 2147483647) with no js/js_reset/end_task/profiles_list live call; the stop takes the normal end path (open task completed, teardown within budget, run/ dir removed, one diagnostics line); the next js/js_reset relaunches lazily and its result opens with a restart notice. Calls racing the stop wait for it. cua agent install carries the variable into the launchd/systemd job. Review: reviewer-medium (opus) found one P2 (setTimeout overflow above 2^31-1 ms → refused as invalid_setting) and two P3 (waiting call counted as open local task; leftover run dir reused), all fixed with regression tests. Gates: npm test 1094 pass/1 Linux-only skip, test:mods 32/32, plugin validate ok. Live check with a 4 s setting: stop after 4 s, relaunch in 457 ms with the notice. Left out: idle stops do not apply to remote devices (their agent runs its own timer); the leftover-dir test fakes the failed removal. Installed plugin updated to 0.9.0 (restart to apply).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementpriority:P3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions