agentleFS
open-thoughtsopen-thoughts/OpenThoughts-Agent/.agents/skills/utils-cleanup-stale-sandboxes/SKILL.md

utils-cleanup-stale-sandboxes

Skill309 starsChanged 4 months agoApache-2.0View on GitHub

Delete stale Daytona sandboxes across ALL THREE orgs (DataComp, DataCompData, DataCompRL) in one pass. Runs `scripts/daytona/cleanup_stale_sandboxes.py` three times — once per org — each time setting the org's API key via `--api-key-env` so the script queries and deletes in the correct org. Default threshold is 60 minutes of inactivity; `--delete` actually removes them (dry run otherwise). Use when the Daytona sandbox count is climbing (eval/datagen/RL sandboxes left behind after jobs finish), when a sweep flags stale sandboxes, or when approaching the org snapshot/sandbox cap.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Delete stale Daytona sandboxes across the three orgs.

    line 16
  2. Distinctive:

    Before a large eval, datagen, or RL launch.

    line 22
  3. Distinctive:

    Dry run first: when unsure.

    line 87

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

utils-cleanup-stale-sandboxes

Delete stale Daytona sandboxes across the three orgs.

When to use

  • Daytona sandbox count is climbing — stale sandboxes left behind after eval / datagen / RL jobs finish.
  • A sweep flags stale sandboxes or the org approaches its cap.
  • Before a large eval, datagen, or RL launch.
  • Routine hygiene during heavy operations.

The three orgs

OrgAPI key env varTypical sandboxes
DataComp (main)DAYTONA_API_KEYEval (terminus-2 agent sandboxes)
DataCompDataDAYTONA_DATA_API_KEYDatagen (trace-generation rollouts)
DataCompRLDAYTONA_RL_API_KEYRL (SkyRL/GRPO agentic rollouts)

Source $DC_AGENT_SECRET_ENV to set all three variables. --api-key-env selects the org for each invocation.

How to invoke

Locally (Mac) — uses the otagent conda env's Python:

set -a; source "${DC_AGENT_SECRET_ENV:?set DC_AGENT_SECRET_ENV to the secrets file first}"; set +a

PY=/Users/benjaminfeuer/miniconda3/envs/otagent/bin/python
SCRIPT=scripts/daytona/cleanup_stale_sandboxes.py
THRESHOLD=60   # minutes of inactivity

for KEY_ENV in DAYTONA_API_KEY DAYTONA_DATA_API_KEY DAYTONA_RL_API_KEY; do
    echo "============================================"
    echo "Org: $KEY_ENV"
    echo "============================================"
    $PY $SCRIPT --api-key-env "$KEY_ENV" --threshold "$THRESHOLD" --delete
    echo
done

Dry run: omit --delete.

for KEY_ENV in DAYTONA_API_KEY DAYTONA_DATA_API_KEY DAYTONA_RL_API_KEY; do
    $PY $SCRIPT --api-key-env "$KEY_ENV" --threshold "$THRESHOLD"
done

Custom threshold — pass --threshold <minutes> (default 60):

# Only clean sandboxes inactive for >2 hours
THRESHOLD=120

Flags

FlagDefaultPurpose
--deleteoff (dry run)Actually delete stale sandboxes
--threshold60Minutes of inactivity before a sandbox is considered stale
--api-key-envDAYTONA_API_KEYWhich env var holds the org's API key

Gotchas

  • Must source $DC_AGENT_SECRET_ENV first — all three DAYTONA_* env vars must be set before running the loop, or the script will exit with ERROR: ... not set in environment.
  • Run from the otagent env — the daytona SDK must be installed (it is in the otagent conda env; NOT in the base env). Use the full interpreter path /Users/benjaminfeuer/miniconda3/envs/otagent/bin/python.
  • RL (DAYTONA_RL_API_KEY) may have long-lived sandboxes. Raise its threshold if active sandboxes are selected.
  • Dry run first when unsure.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.