Skip to content

fleet spawn --sandbox: persist in-flight async sandbox identity and reconcile on Ctrl-C #1925

Description

@khaliqgant

Follow-up from #1881 review (async-v1 sandbox preparation).

Problem

  • packages/cli/src/cli/commands/fleet.ts:772 mints sbx_${randomUUID()} for every unpinned/agent37 fleet spawn --sandbox and persists nothing. If the CLI process is killed while polling Cloud preparation, a plain re-run creates a second sandbox; the first is only reclaimed by Cloud's 30-minute preparation deadline + reaper (cloud#4137).
  • fleet.ts:826 calls deps.ensureCloudFleetSandbox(ensureInput, { onPreparationProgress }) with no signal, so Ctrl-C does not abort cleanly or reconcile/clean the exact identity.

Mitigation already in #1881
The CLI prints Cloud sandbox identity: sbx_… If this command is interrupted, re-run it with --sandbox-id sbx_… before any Cloud work; re-running with that --sandbox-id resumes the same durable preparation (ensure is idempotent on the exact identity + request).

Proposed

  1. Persist the in-flight {sandboxId, cloudWorkspaceId, request fingerprint} next to the persisted workspace route (state dir) before the first ensure; on the next identical spawn, reconcile it (GET status) instead of minting a new id; clear on ready/terminal.
  2. Wire a SIGINT/SIGTERM AbortController into ensureCloudFleetSandbox; on abort after Cloud accepted the record, print the resume command (and optionally DELETE by exact identity when the user confirms abandonment).

Acceptance: killing the CLI mid-poll and re-running the same command yields one sandbox; Ctrl-C prints the exact resume/cleanup identity.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions