Reclaim Stray Sandboxes

Find and stop sandboxes left behind by a crashed or killed run

Sandboxes normally self-destruct when your run ends. A crashed script, a SIGKILL, or a laptop that slept before teardown can leave one behind β€” burning your Docker daemon, your E2B credits, or your Modal quota. Two commands find and reclaim them.

Diagram

πŸ’₯ Crashed run

πŸ“¦ Stray sandbox

⚑ managed ps

⚑ managed stop

βœ… Reclaimed

Quick Start

  1. See what is still running
    bash
    praisonai managed ps

    If nothing is up:

    text
    No running sandboxes.

    If something is up:

    text
    INSTANCE ID                PROVIDER   STATUS     UPTIME   IMAGE
    ------------------------------------------------------------------------------
    docker_5afaa3bfa704        docker     running    42s      python:3.12-slim
    
    1 running. Stop with: praisonai managed stop <instance-id>
  2. Reclaim it
    bash
    # One
    praisonai managed stop docker_5afaa3bfa704
    
    # All (across every provider)
    praisonai managed stop --all
    
    # All from one provider only
    praisonai managed stop --all --provider docker
  3. Confirm it is gone
    bash
    praisonai managed ps
    # β†’ No running sandboxes.

How It Works

Diagram
Provider (Docker/E2B/…)praisonai managedUserProvider (Docker/E2B/…)praisonai managedUsermanaged pslist by praisonai=managed labelrunning instancestable of sandboxesmanaged stop <id>shut down instancestoppedreclaimed

Docker containers are found cross-process by the praisonai=managed label and the praisonai_<id> name, so containers started by an earlier script are visible from a fresh CLI.


Behaviour change: the silent leak on shutdown

Two collaborating fixes close the leak:

  1. SyncComputeProvider._offload() falls back to inline execution when the executor is gone β€” it catches a RuntimeError whose message contains "interpreter shutdown" or "no running event loop" and calls the sync function directly (blocking is fine: there is no event loop left to starve). Unrelated RuntimeErrors still propagate.
  2. _shutdown_orphan() in tools_placement.py now logs at warning level (was debug), so a genuine teardown failure is visible instead of buried. SharedCompute.shutdown() re-raises the underlying exception after clearing instance_id, so the caller can log it.

If you ran an older version, reclaim any accumulated leaks with praisonai managed ps / managed stop (and docker container prune for stopped-but-not-removed containers).


…and the run_on= finalizer that was never registered (PR #4109)

The PR #4107 fix above only fires when a finalizer actually runs. On ComputeManagedAgent β€” the backend behind run_on= β€” no finalizer had ever been registered, so the release path was never invoked and the instance survived the whole process.