Skip to content

fix(cli): handle stale last-used sandbox after sandbox deletion #172

@pimlock

Description

@pimlock

Problem

nemoclaw sandbox connect (and other commands that use the last used sandbox as a default) can fail when the locally stored last-used sandbox points to a sandbox that no longer exists.

Example:

nemoclaw sandbox connect
→ Using sandbox 'commanding-sasquatch' (last used)
Error:   × status: NotFound, message: "sandbox not found", details: [], metadata: MetadataMap { headers: {"content-type": "application/grpc", "date": "Sun, 08 Mar 2026
  │ 02:56:56 GMT"} }

Context

This came up while running e2e tests against a cluster. The tests updated the local last used sandbox, then the sandbox was deleted, leaving the CLI pointing at a stale sandbox name.

Expected behavior

If the stored last-used sandbox no longer exists, the CLI should recover gracefully instead of failing with sandbox not found.

Possible approaches

  • Delete or reset the stored last-used sandbox when a sandbox is deleted
  • Have e2e tests clean up or restore the last_sandbox file after they run
  • Keep a stack/list of recent sandboxes and fall back to the next valid one when the current one is gone

Acceptance criteria

  • Reproduce the stale last used sandbox case with an automated test
  • nemoclaw sandbox connect no longer hard-fails when the stored sandbox has been deleted
  • The last-used sandbox state is cleaned up or recovered in a predictable way
  • Documentation or behavior is clear enough for users and for e2e test workflows

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