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
In this repository50 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- analyze-datagen-campaign-summarySkill
- analyze-dataset-token-lengthSkill
- analyze-id-eval-rankingSkill
- analyze-job-history-irisSkill
- analyze-rl-behaviorSkill
- analyze-training-run-irisSkill
- build-tpu-image-irisSkill
- code-create-staged-planSkill
- code-execute-staged-planSkill
- commitSkill
- crud-archive-runSkill
- crud-otagent-supabaseSkill
- crud-purge-below-gate-evalsSkill
- crud-purge-stale-eval-placeholdersSkill
- datagen-create-task-datasetSkill
- datagen-job-cleanupSkill
- datagen-launch-irisSkill
- datagen-launchSkill
- datagen-reduce-dataset-snapshotsSkill
- datagen-standard-launchSkill
- debugSkill
- docs-deslopSkill
- eval-agentic-cleanupSkill
- eval-agentic-launch-irisSkill
- eval-agentic-launchSkill
- eval-standard-cleanupSkill
- eval-standard-launchSkill
- file-issueSkill
- monitor-cron-sweep-irisSkill
- monitor-cron-sweepSkill
- monitor-job-tablesSkill
- monitor-restore-irisSkill
- monitor-restoreSkill
- monitor-restore-unifiedSkill
- rl-agentic-job-cleanupSkill
- rl-agentic-launch-irisSkill
- rl-agentic-launch-jupiterSkill
- rl-job-health-deep-diveSkill
- rl-standard-job-cleanupSkill
- rl-standard-launch-leonardoSkill
- serve-model-vibe-testSkill
- sft-cleanup-hf-onlySkill
- sft-job-cleanupSkill
- sft-launchSkill
- supervisor-initSkill
- utils-fix-permissionsSkill
- utils-reclaim-stale-snapshotsSkill
- write-testsSkill
- writing-styleSkill
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
- Distinctive: line 16
Delete stale Daytona sandboxes across the three orgs.
- Distinctive: line 22
Before a large eval, datagen, or RL launch.
- Distinctive: line 87
Dry run first: when unsure.
≈ “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.
Files
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
| Org | API key env var | Typical sandboxes |
| DataComp (main) | DAYTONA_API_KEY | Eval (terminus-2 agent sandboxes) |
| DataCompData | DAYTONA_DATA_API_KEY | Datagen (trace-generation rollouts) |
| DataCompRL | DAYTONA_RL_API_KEY | RL (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
doneDry 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"
doneCustom threshold — pass --threshold <minutes> (default 60):
# Only clean sandboxes inactive for >2 hours
THRESHOLD=120Flags
| Flag | Default | Purpose |
--delete | off (dry run) | Actually delete stale sandboxes |
--threshold | 60 | Minutes of inactivity before a sandbox is considered stale |
--api-key-env | DAYTONA_API_KEY | Which env var holds the org's API key |
Gotchas
- Must source
$DC_AGENT_SECRET_ENVfirst — all threeDAYTONA_*env vars must be set before running the loop, or the script will exit withERROR: ... not set in environment. - Run from the otagent env — the
daytonaSDK must be installed (it is in theotagentconda 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.
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
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.

