agentleFS
open-thoughtsopen-thoughts/OpenThoughts-Agent/.agents/skills/utils-reclaim-stale-snapshots/SKILL.md

utils-reclaim-stale-snapshots

Skill309 starsChanged 4 months agoApache-2.0View on GitHub

Reclaim idle Daytona SNAPSHOTS org-wide to free space under the 60-snapshot cap, using scripts/daytona/daytona_snapshot_manager.py. Deletes only harbor__ per- environment snapshots idle past the standing threshold GT'd in .agents/projects/daytona/daytona.md — NEVER the shared base/template images (daytonaio/sandbox:*, daytona-*, windows-*), which do not rebuild-on-demand. Use when a datagen/eval launch hits SnapshotCapExceeded, when a monitor sweep finds the cap full, or as routine cap hygiene. This is the org-wide RECLAIM tool; to shrink a SINGLE dataset's unique-environment count instead, use datagen-reduce-dataset-snapshots. Snapshots are a DIFFERENT resource from sandboxes (for sandbox cleanup use utils-cleanup-stale-sandboxes).

  • Reads credentials

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    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:

    Always audit (read-only) first, then delete.

    line 37

≈ “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-reclaim-stale-snapshots

Free Daytona snapshot quota by deleting idle harbor__<hash>__snapshot environments under the hard cap of 60.

Why this is safe (and what it must never touch)

Harbor builds one snapshot per task-environment hash (harbor__<hash>__snapshot). auto_snapshot rebuilds a deleted idle snapshot on demand.

The base/template images (daytonaio/sandbox:*, daytona-gpu, daytona-medium/large/small, windows-*) are shared and do not rebuild on demand. Keep --name-prefix harbor__ so only Harbor snapshots are eligible.

For snapshots, state=active means built and available. Staleness uses last_used_at, falling back to created_at; live-job environments remain below the idle threshold.

Which org

Datagen/eval pre-build uses the cli org and DAYTONA_API_KEY. RL uses the separate DAYTONA_RL_API_KEY org.

How to run

Always audit (read-only) first, then delete.

cd /Users/benjaminfeuer/Documents/OpenThoughts-Agent
source /Users/benjaminfeuer/miniconda3/etc/profile.d/conda.sh && conda activate otagent
source "${DC_AGENT_SECRET_ENV:?set DC_AGENT_SECRET_ENV to the secrets file first}"
PY=/Users/benjaminfeuer/miniconda3/envs/otagent/bin/python
SCRIPT=scripts/daytona/daytona_snapshot_manager.py

# 1. AUDIT — read-only, see what WOULD be reclaimed (at the stale threshold — see below)
$PY $SCRIPT --api-key-env DAYTONA_API_KEY --stale-days <threshold>

# 2. RECLAIM — actually delete the stale harbor__ snapshots
$PY $SCRIPT --api-key-env DAYTONA_API_KEY --stale-days <threshold> --delete-stale --yes

--stale-days accepts floats; use minutes/1440 for sub-day thresholds. The standing threshold is in .agents/projects/daytona/daytona.md § "How to clean stale snapshots". Raise it for more conservative cleanup.

Flags (this tool)

FlagDefaultPurpose
--api-key-envDAYTONA_DATA_API_KEYOrg key env var. Use DAYTONA_API_KEY for the cli/datagen org.
--stale-days14Idle-days threshold (float). Standing value GT'd in .agents/projects/daytona/daytona.md § "How to clean stale snapshots" — don't restate it here.
--name-prefixharbor__Only names starting with this are deletable. Do not widen it — the default guards base images.
--delete-staleoff (dry-run)Actually delete.
--yesoffSkip the confirm prompt (for scripted/cron use).
--jsonoffMachine-readable output.

Gotchas

  • Source $DC_AGENT_SECRET_ENV + otagent env — the daytona SDK lives in the otagent conda env; use the full interpreter path.
  • Never pass --name-prefix '' with --delete-stale — that would make base images deletable. The tool is safe only with the harbor__ default.
  • Idle active harbor__ snapshots are reclaimable.
  • Reclaiming adds a one-time rebuild when the environment is next used.

In the monitor sweep

The every-3-hours Iris sweep audits each tick and reclaims for blocked datagen refills or cap ≥ ~58/60. See monitor-cron-sweep-iris §5.

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.