OpenComputer sandboxes can change size at runtime. There are three knobs:Documentation Index
Fetch the complete documentation index at: https://docs.opencomputer.dev/llms.txt
Use this file to discover all available pages before exploring further.
| What you want | Use |
|---|---|
| Resize once, predictably | scale() |
| Track memory pressure automatically | setAutoscale() |
| Freeze the current size | setScalingLock() |
1024, 4096, 8192, 16384, 32768, 65536 MB. CPU follows memory per the platform’s tier table (e.g. 8 GB → 4 vCPU). You don’t pick CPU separately.
How the three interact
- Manual
scale()disables autoscale on the sandbox as a side effect — explicit user intent overrides the loop. Re-enable autoscale withsetAutoscale({ enabled: true, ... })after if you want. - Setting a scaling lock disables autoscale at the same time (single-knob: “I don’t want this scaling, period”). While locked, both
scale()andsetAutoscale({ enabled: true })reject withScalingLockedError. Unlocking does NOT auto-re-enable autoscale. - Plan caps apply everywhere. Free-tier orgs are capped at 4 GB. Calls above the cap throw
PlanLimitError.
sandbox.scale(opts)
Manually resize the sandbox. HTTP API →
Target memory tier in MB. Must be one of the allowed tiers.
Promise<{ sandboxID: string; memoryMB: number; cpuPercent: number }>
Throws:
ScalingLockedError— sandbox has a scaling lock active.PlanLimitError—memoryMBexceeds the org’s plan cap.
sandbox.setAutoscale(opts)
Enable or disable per-sandbox autoscale.
Whether autoscale should be active.
Lower bound when
enabled=true. Must be an allowed tier.Upper bound when
enabled=true. Must be an allowed tier and ≥ minMemoryMB.Promise<{ sandboxID: string; enabled: boolean; minMemoryMB: number; maxMemoryMB: number }>
Throws:
ScalingLockedError— sandbox has a scaling lock active.PlanLimitError—maxMemoryMBexceeds the org’s plan cap.
enabled=true, the platform watches the sandbox’s memory pressure and resizes it within the bounds:
- Scale up on a single 1-min sample above 75% memory utilization. Cooldown 60s between up-scales.
- Scale down only when 1-min, 5-min, AND 15-min averages all sit below 25%. Cooldown 5 min between down-scales.
sandbox.getAutoscale()
Get the current autoscale configuration.
Returns: Promise<{ sandboxID: string; enabled: boolean; minMemoryMB: number; maxMemoryMB: number }>
sandbox.setScalingLock(locked)
Lock or unlock the sandbox’s resources against any size change.
true to freeze, false to allow scaling again.Promise<{ sandboxID: string; locked: boolean }>
While locked:
scale()rejects withScalingLockedError.setAutoscale({ enabled: true })rejects withScalingLockedError.- The platform autoscaler skips this sandbox entirely.
setAutoscale({ enabled: true, ... }) explicitly if you want it back.
sandbox.getScalingLock()
Get the current scaling-lock state.
Returns: Promise<{ sandboxID: string; locked: boolean }>
Errors
ScalingLockedError
Thrown when the sandbox has a scaling lock active. Has a code property of "scaling_locked" for parity with the HTTP API’s error code.