When running large-scale AI agent workloads, hibernate and wake up sandbox instances manually by using the E2B SDK or the Sandbox custom resource (CR). Automatic hibernation and wake-up can also be based on running-state probes, scheduled tasks, or inbound traffic. These methods reduce idle compute costs and improve cluster resource utilization.
Scope
-
The following prerequisite is met: Create an Agent Sandbox.
-
Only Sandbox instances created on or after March 5, 2026, or instances created by the
ack-agent-sandbox-controlleradd-on version 0.5.8 or later, are supported.Run
kubectl get sandbox <RESOURCE_NAME> -o yamlto check themetadata.creationTimestampfield. If the instance does not meet either of the preceding conditions, create the Sandbox again. -
Setting the hibernation retention time through the E2B SDK requires the
ack-sandbox-manageradd-on version 0.6.7 or later. For versions earlier than 0.6.7, the retention period for hibernated sandboxes is controlled by the add-on'smaxTimeoutparameter. For details, see the following section: Compatibility configuration for ack-sandbox-manager add-on versions earlier than 0.6.7. -
Probe-driven automatic hibernation and scheduled wake-up require the
ack-agent-sandbox-controlleradd-on version v0.6.6-release.1 or later, and theAutoPauseControllerfeature enabled.
Hibernation strategies
Prerequisites: Configuring spec.pauseStrategy requires ack-agent-sandbox-controller add-on version v0.6.1-release.2 or later.
spec.pauseStrategy is an optional field that specifies the hibernation method used when spec.paused is set to true. If this field is not configured, hibernation based on a cloud disk is used by default, which is consistent with existing behavior, and your existing configurations require no changes.
|
Hibernation strategy |
Configuration |
What is retained |
|
Cloud disk hibernation (default) |
Do not configure |
Before hibernation, the file system state (rootfs) of the Sandbox is saved to a cloud disk, consistent with existing behavior. |
|
Stop |
|
Hibernates the Sandbox without saving its state. Only PersistentVolumeClaim (PVC) data is retained, and the rootfs filesystem is lost. |
|
Snapshot hibernation |
|
Before hibernation, the file system state (rootfs) of the Sandbox is saved to a snapshot. |
Stop strategy configuration
apiVersion: agents.kruise.io/v1alpha1
kind: SandboxSet
metadata:
name: code-interpreter
namespace: default
spec:
replicas: 4
pauseStrategy:
type: Stop
template:
spec:
containers:
- image: registry-<REGION_ID>-vpc.ack.aliyuncs.com/acs/code-interpreter:v1.6
name: sandbox
resources:
limits:
cpu: "1"
memory: 1Gi
requests:
cpu: "1"
memory: 1Gi
Snapshot hibernation strategy configuration
apiVersion: agents.kruise.io/v1alpha1
kind: SandboxSet
metadata:
name: code-interpreter
namespace: default
spec:
replicas: 4
pauseStrategy:
type: Hibernate
hibernateStrategy:
type: Snapshot
persistentContents: # Only filesystem (rootfs) is supported
- filesystem
template:
spec:
containers:
- image: registry-<REGION_ID>-vpc.ack.aliyuncs.com/acs/code-interpreter:v1.6
name: sandbox
resources:
limits:
cpu: "1"
memory: 1Gi
requests:
cpu: "1"
memory: 1Gi
Hibernate a Sandbox
Hibernating a Sandbox releases idle resources to optimize running costs. Trigger hibernation only when no active requests or long-lived connections exist. For the complete list of limits, see Limits in this topic.
For billing details in the hibernated state, see Agent Sandbox billing.
E2B SDK method
If you set "e2b.agents.kruise.io/never-timeout": "true" when you create a Sandbox, the system does not use the E2B timeout to generate spec.pauseTime or spec.shutdownTime. Therefore, an E2B timeout does not trigger automatic hibernation or deletion. A configured autoPausePolicy can still trigger hibernation and wake-up independently.
Automatic hibernation
When you create a Sandbox, configure the relative timeout timeout (in seconds) and set lifecycle.on_timeout to pause. ack-sandbox-manager then calculates an absolute time in RFC 3339 format as “current server time + timeout” and writes it to spec.pauseTime. The E2B client passes only the relative timeout and does not read or set pauseTime.
In the following example, the Sandbox is automatically hibernated 600 seconds after it is created and is retained in the hibernated state for 24 hours:
# Import the E2B SDK
from e2b_code_interpreter import Sandbox
sandbox: Sandbox = Sandbox.create(
template="code-interpreter",
timeout=600,
lifecycle={"on_timeout": "pause"},
metadata={
# Sandbox is retained for 24 hours after it enters the hibernated state
"e2b.agents.kruise.io/reserve-paused-sandbox-duration": "24h",
},
)
# Run your workload
sandbox.run_code("print('hello, world')")
Manual hibernation
After confirming that the task is complete, call the hibernation API to suspend the Sandbox and release compute resources.
Replace the following <YOUR_SANDBOX_ID> with the actual Sandbox ID. This example sets the hibernation retention time to 24 hours:
# Import the E2B SDK
from e2b_code_interpreter import Sandbox
# Connect to the Sandbox
sandbox = Sandbox.connect("<YOUR_SANDBOX_ID>")
# Manually hibernate the Sandbox and set the hibernation retention time to 24 hours
sandbox.pause(
headers={
"x-e2b-kruise-reserve-paused-sandbox-duration": "24h",
}
)
Hibernation retention time
The retention timer starts when the Sandbox enters hibernation. If the retention time is reached and the Sandbox has not been woken up, the system automatically deletes the Sandbox. When the Sandbox hibernates again after a wake-up, the timer restarts from the new hibernation time.
Value format: a Go duration string, such as 30m, 24h, and 168h (write 7 days as 168h; 7d is not supported). If you do not set this field, the default value is forever (retained permanently).
The value must be greater than 0. If the value is empty, has an invalid format, or is less than or equal to 0, the creation or hibernation request fails.
Priority: in descending order, the manual hibernation header configuration, the header configuration from creation or the last manual hibernation, and the default value forever.
Sandbox CR method
Set spec.paused to true in the Sandbox instance configuration.
# Before you run this command, replace <RESOURCE_NAME> with the resource name and <NAMESPACE> with the namespace of the resource.
kubectl patch sandbox <RESOURCE_NAME> -n <NAMESPACE> --type='merge' -p '{"spec":{"paused":true}}'
By default, the system does not automatically delete a Sandbox CR in the hibernated state. To set an automatic deletion time, modify thespec.shutdownTimefield (an absolute timestamp in RFC 3339 format, such as2026-12-31T23:59:59+08:00) in the Sandbox resource to the expected deletion time.
After hibernating the Sandbox by using either method, go to the cluster details page and choose Workloads > Custom Resources, and then filter the list to view the hibernation status of the Sandbox.
Wake up a Sandbox
E2B SDK method
Quickly wake up a hibernated Sandbox by using the connect operation. Replace the following <YOUR_SANDBOX_ID> with the actual Sandbox ID. timeout is an optional parameter that resets the relative timeout (unit: seconds) from the time this connection is established: if the Sandbox uses automatic hibernation mode, the system refreshes spec.pauseTime; otherwise, it refreshes spec.shutdownTime. connect uses the Sandbox's existing timeout mode and does not accept lifecycle.on_timeout again.
# Import the E2B SDK
from e2b_code_interpreter import Sandbox
# Connect to the Sandbox; if the Sandbox is hibernated, a wake-up is triggered automatically and the context is restored
sandbox = Sandbox.connect(
"<YOUR_SANDBOX_ID>",
timeout=600, # Hibernate or destroy the Sandbox 600 seconds after this connection starts, based on its existing timeout mode
)
# Continue to run your workload
sandbox.run_code("print('hello, world')")
Waking up a Sandbox does not clear the already-configured hibernation retention policy. When the Sandbox enters the hibernated state again, the system recalculates the retention time from the actual hibernation time.
Sandbox CR method
Set spec.paused to false in the Sandbox instance configuration.
# Before you run this command, replace <RESOURCE_NAME> with the resource name and <NAMESPACE> with the namespace of the resource.
kubectl patch sandbox <RESOURCE_NAME> -n <NAMESPACE> --type='merge' -p '{"spec":{"paused":false}}'
After you wake up the Sandbox, go to the cluster details page and choose Workloads > Pods, and then filter the list to view the running status of the Sandbox.
Automatic hibernation and wake-up based on probes and traffic
For continuously running agents with periodic tasks, configure the running-state probes and the automatic hibernation and wake-up policies together in a SandboxSet. The system delivers the configuration to the Sandbox. A claimed instance automatically hibernates after it continuously reports an idle state, and automatically wakes up before the next scheduled task runs or when inbound traffic arrives.
Before using automatic hibernation and wake-up, verify the required add-on versions and access path for your scenario:
-
When you use a probe for automatic hibernation or scheduled wake-up, the
ack-agent-sandbox-controllerversion must be >= v0.6.6-release.1. -
To automatically wake up a Sandbox based on inbound traffic, see Manage Agent Sandbox ingress traffic. The
ack-sandbox-managerversion must be >= v0.6.12-release.1.
How probes work and common configurations
spec.probes is a common field in SandboxSet.spec that defines the probes to run periodically while the Sandbox is running. A probe only runs a command and reports the result. It does not determine whether the Sandbox hibernates or wakes up. spec.autoPausePolicy references the corresponding result by probe name and interprets the standard output based on different rules:
-
The automatic hibernation rule uses
messageRegexto match the probe output and determine whether the agent is idle. -
The scheduled wake-up rule uses
timeFormatto parse the probe output into the next task time.
spec.probes does not depend on autoPausePolicy. You can run a probe on its own and view the result in the Sandbox condition even when no automatic hibernation or wake-up policy is configured. After you configure a policy, the policy reads the condition of the corresponding probe by name. One or more policies can reference the same probe, but automatic hibernation and scheduled wake-up usually require different output formats. Define a separate probe for each purpose, as with Active and Cron in this example.
Only probes of the exec type are supported.
|
Field |
Required |
Description |
|
|
Yes |
The custom name of the probe. The name must be unique within the same SandboxSet and must exactly match the |
|
|
No |
The name of the container in which the probe runs. If this field is not configured, the first container in the pod is used by default. |
|
|
Yes |
The command and its parameters to run in the target container. The command is not automatically run through a shell. To use pipes, redirection, or conditional statements, explicitly configure |
|
|
No |
The interval at which the probe runs, in seconds. The example value |
|
|
No |
The timeout for a single probe run, in seconds. The example value |
When a probe command exits with code 0, the status of the condition is True, and the standard output is recorded in the message of the condition. When a command fails or times out, its output is not used to trigger automatic hibernation or scheduled wake-up. Express both the business status and the task time through the standard output, and do not write debug logs to the standard output.
Automatic hibernation based on the running state
The following SandboxSet example checks whether the agent is active every 30 seconds. A claimed Sandbox is automatically hibernated after the Active probe reports the idle state for 10 consecutive minutes.
The command in the example only demonstrates the input and output conventions of probes. Define the idle state based on your business requirements.
apiVersion: agents.kruise.io/v1alpha1
kind: SandboxSet
metadata:
name: agent-sandbox-pool
namespace: default
spec:
replicas: 4
probes:
- name: Active
containerName: sandbox
periodSeconds: 30
timeoutSeconds: 5
exec:
command:
- sh
- -c
- |
# Example only. Define the idle state based on your business requirements.
if openclaw sessions list --active 900 2>/dev/null | grep -q .; then
echo "active"
else
echo "inactive"
fi
autoPausePolicy:
pause:
whenProbedIdleState:
probe: Active
messageRegex: "^inactive$"
thresholdDuration: 10m
template:
spec:
containers:
- name: sandbox
image: <YOUR_IMAGE>
Active probe output
-
Activeis the probe that runs an idle detection command in thesandboxcontainer every 30 seconds. This name is the same as the value ofautoPausePolicy.pause.whenProbedIdleState.probe. -
In the example,
openclaw sessions list --active 900queries the active sessions within the past 900 seconds (15 minutes). Thengrep -q .checks whether the command returns a non-empty result:activeis output when active sessions exist, andinactiveis output otherwise.2>/dev/nullprevents error messages from being written to the standard output of the probe. The900parameter is only an example. Adjust it based on how your business defines the idle state. -
The probe must exit with code 0 and return only
activeorinactivein the standard output. Thestatusof the condition indicates whether the probe ran successfully. The business status is indicated bymessage.
autoPausePolicy configuration
-
pause.whenProbedIdleState.probereferences thespec.probesentry for theActiveprobe, andmessageRegex: "^inactive$"matches the idle state returned by the probe. -
thresholdDurationis required and cannot be a negative value. When it is set to10m, timing starts when the probe first returnsinactive. If the probe continues to returninactivefor the next 10 minutes, the Sandbox is automatically hibernated. When it is set to 0, the Sandbox hibernates immediately after the probe first returnsinactive. In the example,--active 900treats a session with activity in the past 15 minutes as active. Therefore, if no new activity occurs, hibernation usually begins about 25 minutes after the last session activity: a 15-minute activity window plus a 10-minute continuous idle period. -
If the idle probe times out, fails, or has an invalid configuration, the system keeps the Sandbox running as a precaution. A pre-warmed Sandbox managed by the SandboxSet but not yet claimed can run probes. It does not participate in automatic hibernation decisions, and the policy hibernates it only after it is claimed.
Sandbox status example
The following example shows the status of a Sandbox that has not yet hibernated and is waiting for the idle threshold to expire. After the Active probe first returns inactive, the controller immediately calculates the expected hibernation time based on the lastTransitionTime and thresholdDuration of the condition, and writes it to nextPauseTime. For example, when the probe keeps reporting the idle state starting from 2026-09-09T10:00:00Z and thresholdDuration is 10 minutes, the status is as follows:
apiVersion: agents.kruise.io/v1alpha1
kind: Sandbox
status:
phase: Running
conditions:
- type: agents.kruise.io/Active
status: "True"
reason: Succeeded
message: inactive
lastTransitionTime: "2026-09-09T10:00:00Z"
schedules:
- reason: probedIdle
nextPauseTime: "2026-09-09T10:10:00Z"
In this example, the type of the condition consists of the fixed prefix agents.kruise.io/ and the probe name Active. If you change the probe name, the condition type changes accordingly. status: "True" indicates that the probe ran successfully. The actual business status is indicated by message: inactive. nextPauseTime is the expected hibernation time calculated from the current idle state. It does not mean that hibernation has been triggered. If the probe returns active before that time, the controller clears nextPauseTime, and the Sandbox keeps running. If the probe continues to return inactive until that time, the controller triggers hibernation and clears nextPauseTime.
Automatic wake-up before scheduled tasks
The following SandboxSet example obtains the Unix timestamp in seconds for the next scheduled task every 30 seconds. It automatically wakes up the hibernated Sandbox 5 minutes before the task runs.
The command in the example only demonstrates the input and output conventions of probes. Obtain the next task time based on your business requirements.
apiVersion: agents.kruise.io/v1alpha1
kind: SandboxSet
metadata:
name: agent-sandbox-pool
namespace: default
spec:
replicas: 4
probes:
- name: Cron
containerName: sandbox
periodSeconds: 30
timeoutSeconds: 5
exec:
command:
- sh
- -c
- |
# Example only. Obtain the next task time based on your business requirements.
NEXT_MS=$(openclaw cron list --json 2>/dev/null \
| jq -r '[.[] | select(.enabled != false) | .nextRunAtMs] | map(select(. != null)) | sort | .[0]')
if [ -n "$NEXT_MS" ] && [ "$NEXT_MS" != "null" ]; then
echo $((NEXT_MS / 1000))
else
echo "none"
fi
autoPausePolicy:
resume:
whenProbedScheduleTime:
probe: Cron
timeFormat: unix
leadTime: 5m
template:
spec:
containers:
- name: sandbox
image: <YOUR_IMAGE>
Cron probe output
-
Cronis the probe that gets the next task time in thesandboxcontainer every 30 seconds. This name is the same as the value ofautoPausePolicy.resume.whenProbedScheduleTime.probe. -
The example first runs
openclaw cron list --jsonto obtain the scheduled task entries of the agent. It then usesjqto filter the enabled tasks that containnextRunAtMs, sorts them by time, and takes the earliest task.nextRunAtMsis a Unix timestamp in milliseconds, so it must be divided by 1000 before it is output. -
The probe must exit with code 0 and return only one value in the standard output. The current example configures
timeFormat: unix, so the returned value must be a positive integer that represents a Unix timestamp in seconds, such as1788516000. The controller strips the leading and trailing spaces and line breaks of the output, but cannot parse timestamps in milliseconds, values with units, date strings, JSON, or mixed log content. -
When no next task exists, the script outputs
none. This value indicates that no task time is currently available, and the controller does not generate a scheduled wake-up plan.
autoPausePolicy configuration
-
resume.whenProbedScheduleTime.probereferences thespec.probesentry for theCronprobe. -
timeFormatspecifies how to parse the standard output of the probe. The example valueunixspecifies that the output is parsed as a Unix timestamp in seconds. The default value is alsounixwhen this field is not configured. It can also be set todatetimeto parse the output as an RFC 3339 time that contains time zone information. -
leadTimespecifies the lead time for wake-up. The example value5msubtracts 5 minutes from the next task time reported by the probe to obtain the expected wake-up time of the Sandbox. The default value is 5 minutes when this field is not configured. A value of 0 wakes up the Sandbox at the task time, and a negative value is not allowed. -
This example configures only automatic wake-up. The Sandbox must first enter the hibernated state through a manual operation,
spec.pauseTime, or another automatic hibernation rule. To achieve both automatic hibernation when idle and scheduled wake-up, combine thepauseandresumeconfigurations of the two examples. -
When the scheduled wake-up probe is not yet available or fails to run, no scheduled wake-up plan is generated. If an automatic hibernation rule is also configured, the system does not trigger automatic hibernation either. When the probe runs successfully but its output cannot be parsed, no scheduled wake-up plan is generated, but the idle rule can still trigger hibernation.
Sandbox status example
The following example shows the status after the Cron probe successfully returns the next task time. 1788516000 indicates 2026-09-04T10:00:00Z, and leadTime is 5 minutes, so the controller writes the expected wake-up time to nextResumeTime:
apiVersion: agents.kruise.io/v1alpha1
kind: Sandbox
status:
phase: Running
conditions:
- type: agents.kruise.io/Cron
status: "True"
reason: Succeeded
message: "1788516000"
lastTransitionTime: "2026-09-04T09:50:00Z"
schedules:
- reason: probedSchedule
nextResumeTime: "2026-09-04T09:55:00Z"
The type of the condition consists of the fixed prefix agents.kruise.io/ and the probe name Cron. status: "True" indicates that the probe ran successfully, and message is the standard output of the probe. nextResumeTime is the expected wake-up time calculated from the task time and leadTime. After the Sandbox enters hibernation, the controller uses the recorded nextResumeTime to trigger wake-up. If the probe later reports a new task time, the controller recalculates this value; if the output is none or other content that cannot be parsed, the value is cleared.
probes, autoPausePolicy, pauseStrategy, and persistentContents are all top-level fields of SandboxSet.spec; spec.template.spec configures only pod template fields such as containers, resources, and scheduling.
Time and time zone requirements for scheduled wake-up
The system calculates the wake-up time by subtracting leadTime from the next task time that the probe reports. leadTime is a pure duration. The default value is 5 minutes. You can set it to 0, but it cannot be a negative value.
-
timeFormat: unix: The probe must output a positive integer that represents a Unix timestamp in seconds, such as1788516000. A Unix timestamp is the number of seconds accumulated since1970-01-01T00:00:00Z. It corresponds to a globally uniform absolute moment and carries no time zone itself. As long as the probe returns the correct timestamp in seconds, deploying the controller in a different region or with a different time zone does not change the wake-up moment. WhentimeFormatis not configured, the output is parsed asunixby default. -
timeFormat: datetime: The probe must output an RFC 3339 time that contains time zone information, such as2026-09-04T18:00:00+08:00or2026-09-04T10:00:00Z. These two values indicate the same moment. A value such as2026-09-04 18:00:00, which contains no time zone and does not conform to RFC 3339, cannot be parsed.
Time zone risks mainly occur when the probe converts a local business time to a Unix timestamp. For example, if the business time is 2026-09-04 18:00:00 in Beijing time, the conversion must explicitly use the +08:00 offset or the Asia/Shanghai time zone. If the time is incorrectly parsed as UTC, an 8-hour deviation occurs. A correctly generated Unix timestamp is no longer affected by the time zone of the controller.
Also confirm the unit of the timestamp. JavaScript's Date.now() and nextRunAtMs in the example return timestamps in milliseconds, which must be divided by 1000 before output. The controller does not automatically detect or convert timestamps in milliseconds.
Use unix and ensure that the probe directly outputs a positive integer that represents a Unix timestamp in seconds. If the next task occurs at 2026-09-04T18:00:00+08:00, its Unix timestamp in seconds is 1788516000. When leadTime is 5 minutes, the system automatically wakes up the Sandbox at 2026-09-04T17:55:00+08:00 on the same absolute timeline.
Relationship between autoPausePolicy, pauseTime, and E2B timeout
-
spec.autoPausePolicyis a probe-based policy that stays in effect continuously. It can hibernate the Sandbox based on the idle state and wake up the Sandbox based on the next task time. -
Sandbox.spec.pauseTimeis a one-time absolute hibernation time in RFC 3339 format. When that time is reached, the controller setsspec.pausedtotrue. -
autoPausePolicyandpauseTimecan be configured at the same time and take effect independently; whichever condition is met first triggers hibernation. Even if the probe reports that the agent is active, an expiredpauseTimeis not canceled. -
When you create a Sandbox through the E2B SDK, the client passes only the relative number of seconds
timeout. Whenlifecycle.on_timeoutispause, ack-sandbox-manager converts it to aspec.pauseTimecalculated as the current server time plus timeout. The E2B client is not directly aware ofpauseTime.
To leave hibernation fully determined by probe policies, do not set spec.pauseTime in the Sandbox CR. When you create or claim a Sandbox through E2B, set "e2b.agents.kruise.io/never-timeout": "true" to avoid generating pauseTime or shutdownTime. This setting does not affect how autoPausePolicy modifies spec.paused.
Automatic wake-up based on inbound traffic
To allow inbound requests to wake up a hibernated Sandbox automatically, configure this feature by using the E2B SDK or the SandboxSet CR. This feature takes effect only for requests that access the agent through Sandbox Gateway.
E2B SDK method
When you create a Sandbox, set lifecycle.on_timeout to pause, and set lifecycle.auto_resume to True:
from e2b_code_interpreter import Sandbox
sandbox = Sandbox.create(
template="code-interpreter",
timeout=600,
lifecycle={
"on_timeout": "pause",
"auto_resume": True,
},
)
# Get the Sandbox access URL for the specified port
host = sandbox.get_host(3000)
print(f"https://{host}")
The Sandbox is automatically hibernated after the timeout elapses. During hibernation, sending a request to the Sandbox access URL triggers automatic wake-up without calling Sandbox.connect(). After wake-up, the automatic hibernation countdown restarts from the wake-up moment based on the timeout configured at creation time. A positive value less than 5 minutes is treated as 5 minutes.
auto_resumesupports automatic wake-up only for inbound traffic sent to the Sandbox access URL.sandbox.commands,sandbox.files, and other SDK operations do not directly trigger automatic wake-up. To perform such operations, callSandbox.connect()first.
SandboxSet CR method
Configure spec.autoPausePolicy.resume.onIngressTraffic
apiVersion: agents.kruise.io/v1alpha1
kind: SandboxSet
spec:
autoPausePolicy:
resume:
onIngressTraffic:
pauseTimeout: 5m
pauseTimeout resets the timeout-based automatic hibernation countdown after the Sandbox is woken up by traffic. This value takes effect only for Sandboxes that have spec.pauseTime configured. If it is not configured or its value is not greater than 0, the countdown is not reset. A positive value less than 5 minutes is treated as 5 minutes.
Verify automatic hibernation and wake-up configurations
View the probe results and the next automatic hibernation and wake-up times. Replace <RESOURCE_NAME> and <NAMESPACE> with the actual values.
kubectl get sandbox <RESOURCE_NAME> -n <NAMESPACE> -o jsonpath='{.status.conditions}'
kubectl get sandbox <RESOURCE_NAME> -n <NAMESPACE> -o jsonpath='{.status.schedules}'
When a probe runs successfully, the status of the corresponding condition is True, and message is the standard output of the probe. During idle matching, status.schedules displays nextPauseTime; when a valid scheduled task exists, it displays nextResumeTime.
Check the Sandbox status
A pod in the hibernated state does not occupy cluster CPU or memory resources.
-
On the Clusters page, click the name of the target cluster. In the left navigation pane, choose Operations > Prometheus Monitoring.
-
On the Prometheus Monitoring page, choose the tab, and then filter for the target pod to view its metrics.
Delete a hibernated Sandbox
Delete a hibernated Sandbox by using one of the following methods.
E2B SDK
Delete a sandbox instance by using the E2B SDK: Replace <YOUR_SANDBOX_ID> with the actual sandbox ID.
from e2b_code_interpreter import Sandbox
sandbox = Sandbox.connect("<YOUR_SANDBOX_ID>")
sandbox.kill()Sandbox CR
# Before you run the command, replace <NAMESPACE> with the Namespace of the resource and <RESOURCE_NAME> with the name of the CR.
kubectl -n <NAMESPACE> delete sandbox <RESOURCE_NAME>Limits
-
Risk of wake-up failure: Hibernation reclaims the compute resources (vCPU and memory) of the instance. On wake-up, the instance may fail to start because of insufficient inventory or an insufficient account balance. Try again later, or change the instance type or add funds to the account before you wake up the instance.
-
Request interruption and loss of persistent connections: After hibernation is triggered, the system immediately freezes the instance CPU, and in-flight requests time out and fail because of the freeze. After wake-up, persistent connections such as WebSocket, Server-Sent Events (SSE), and gRPC are not automatically restored, and the client must reconnect. Confirm that no requests are in progress and no persistent connections exist before you trigger hibernation.
-
Risk of data loss with the Stop strategy: When you hibernate a Sandbox by using
pauseStrategy.type: Stop, the rootfs and the memory state of the Sandbox are not retained. Data inside the container that was not written to a PVC is lost after wake-up. To retain the container file system state after wake-up, use cloud disk hibernation (default) or snapshot hibernation. For the configuration method, see Hibernation strategies in this topic.
References
-
E2B Sandbox (upstream community documentation, for API semantics reference only; specific values and behavior are subject to this topic)