Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Auto-Eviction

Every running sandbox has a time-to-live (TTL). The TTL establishes an expiration deadline so a sandbox cannot occupy CPU and memory indefinitely. When the TTL is reached, AgentENV automatically pauses or deletes the sandbox so those resources can be reclaimed.

Behavior at Expiration

When a sandbox reaches its TTL, AgentENV performs its configured timeout action:

  • Pause (autoPause: true, the default): preserve the sandbox so it can be resumed later.
  • Delete (autoPause: false): permanently remove the sandbox.

A sandbox configured for deletion keeps its deadline when it is paused, including during a graceful runtime shutdown. AgentENV deletes it after that deadline, even if it remains paused after restart. A sandbox configured for pausing remains available to resume after its deadline.

The timeout action is selected when the sandbox is created. The aenv start command uses the default action, autoPause: true. To delete on expiration instead, create the sandbox through the API with autoPause: false.

Warm start from a template or snapshot:

curl -X POST \
  -H 'X-API-Key: test-key' \
  -H 'Content-Type: application/json' \
  -d '{
    "templateID": "my-template",
    "timeout": 600,
    "autoPause": false
  }' \
  http://127.0.0.1:8000/sandboxes

Cold start from an OCI image:

curl -X POST \
  -H 'X-API-Key: test-key' \
  -H 'Content-Type: application/json' \
  -d '{
    "image": "ubuntu:24.04",
    "timeout": 600,
    "autoPause": false
  }' \
  http://127.0.0.1:8000/sandboxes-cold

Set or Extend the Deadline

aenv start --timeout <seconds> sets the initial TTL. If an automatically paused sandbox is needed again, aenv resume --timeout <seconds> resumes it and sets a new TTL from the resume time. Both commands default to 300 seconds.

For a running sandbox, replace its deadline with an exact number of seconds from now:

aenv timeout <sandbox-id> 600

This sets the deadline to 600 seconds from the time the command is sent. Calling it again replaces the previous deadline, so it can either extend or shorten the remaining time.

To keep a running sandbox alive without shortening a later existing deadline, use the refresh API:

curl -X POST \
  -H 'X-API-Key: test-key' \
  -H 'Content-Type: application/json' \
  -d '{"duration": 600}' \
  http://127.0.0.1:8000/sandboxes/<sandbox-id>/refreshes

Refresh does not shorten the remaining TTL if the current deadline is later. Refresh applies only to a running sandbox; resume a paused sandbox first. If duration is omitted, the server’s default sandbox timeout is used.

aenv connect resumes a paused sandbox when it connects and ensures that its TTL is at least the default 300 seconds.

Paused Retention

A paused retention deletes a sandbox after it stays paused for a set time. It applies to any paused sandbox, whatever its timeout action, so it also limits how long an automatically paused sandbox is kept.

Set it at creation with pausedRetentionSeconds (3600 to 3153600000 seconds), or replace it later:

curl -X PUT \
  -H 'X-API-Key: test-key' \
  -H 'Content-Type: application/json' \
  -d '{"pausedRetentionSeconds": 86400}' \
  http://127.0.0.1:8000/sandboxes/<sandbox-id>/paused-retention
  • The clock starts every time the sandbox is paused, including during a graceful runtime shutdown, and the deadline survives a restart.
  • For a paused sandbox, the request restarts the clock: the sandbox is deleted the given number of seconds after the request.
  • For a running sandbox, the request only stores the retention; it applies from the next pause.
  • null removes the retention.

The sandbox list and detail report the retention as pausedRetentionSeconds and the deletion time of a paused sandbox as expiresAt. When a sandbox configured for deletion (autoPause: false) is paused, expiresAt is the earlier of its timeout deadline and its paused retention deadline.