Skip to content

An open-source, faster Devin alternative

TypeScript

dont expose runtimefloor

Brian Reardon860728e82a62
diff --git a/docs/reference/python-sdk/image.mdx b/docs/reference/python-sdk/image.mdx
index fe32f755..854f0b4f 100644
--- a/docs/reference/python-sdk/image.mdx
+++ b/docs/reference/python-sdk/image.mdx
@@ -106,8 +106,8 @@ image = (
### `image.builder_memory(mb)`
Sets the RAM (in MB) used during the build phase. Raise this when a build OOMs
-(heavy `apt`/`pip`). Does **not** pin the output image — the build is re-snapshotted
-at the runtime floor. Defaults to a generous build-phase size.
+(heavy `apt`/`pip`/`npm`). Defaults to **4096**. Does **not** affect the resulting
+sandbox's memory — size that at create time via `memory_mb`.
<ParamField body="mb" type="int" required>
Build-phase memory in MB
@@ -115,18 +115,6 @@ at the runtime floor. Defaults to a generous build-phase size.
**Returns:** `Image`
-### `image.runtime_memory(mb)`
-
-Sets the memory floor (in MB) of the resulting image. Forks can't run below this
-but can scale up. Defaults to 1024. Raise only for images whose services
-auto-start heavy at boot.
-
-<ParamField body="mb" type="int" required>
- Memory floor in MB
-</ParamField>
-
-**Returns:** `Image`
-
---
## Utility Methods
diff --git a/docs/reference/typescript-sdk/image.mdx b/docs/reference/typescript-sdk/image.mdx
index c8f689ee..9f11549c 100644
--- a/docs/reference/typescript-sdk/image.mdx
+++ b/docs/reference/typescript-sdk/image.mdx
@@ -118,8 +118,8 @@ const image = Image.base()
### `image.builderMemory(mb)`
Sets the RAM (MB) used during the build phase. Raise this when a build OOMs
-(heavy `apt`/`pip`). Does **not** pin the output image — the build is
-re-snapshotted at the runtime floor. Defaults to a generous build-phase size.
+(heavy `apt`/`pip`/`npm`). Defaults to **4096**. Does **not** affect the resulting
+sandbox's memory — size that at create time via `memoryMB`.
<ParamField body="mb" type="number" required>
Build-phase memory in MB
@@ -127,18 +127,6 @@ re-snapshotted at the runtime floor. Defaults to a generous build-phase size.
**Returns:** `Image`
-### `image.runtimeMemory(mb)`
-
-Sets the memory floor (MB) of the resulting image. Forks can't run below this
-but can scale up. Defaults to 1024. Raise only for images whose services
-auto-start heavy at boot.
-
-<ParamField body="mb" type="number" required>
- Memory floor in MB
-</ParamField>
-
-**Returns:** `Image`
-
---
## Utility Methods
diff --git a/docs/sandboxes/templates.mdx b/docs/sandboxes/templates.mdx
index 44976f5e..803e2b48 100644
--- a/docs/sandboxes/templates.mdx
+++ b/docs/sandboxes/templates.mdx
@@ -90,21 +90,23 @@ When you pass an `image` to `Sandbox.create()`, the server:
2. If cached, creates the sandbox from the existing checkpoint instantly
3. If not cached, boots a build sandbox, executes each step, checkpoints the result, then creates your sandbox from it
-### Build vs. runtime memory
+### Build memory
-Two independent, optional knobs control the memory used while *building* the image versus the memory *floor* of the resulting image:
+Images build in a **4 GB** sandbox by default. If a build runs out of memory (heavy `apt`/`pip`/`npm`, compiling a large toolchain), raise the build-phase RAM with **`.builderMemory(mb)` / `.builder_memory(mb)`**.
-- **`.builderMemory(mb)` / `.builder_memory(mb)`** — RAM for the build phase. Raise it when a build OOMs (heavy `apt`/`pip`/`npm`). It does **not** pin the output: the builder cold-boots a fresh VM from the built disk at the runtime floor and snapshots that, so a large build still forks down cheaply.
-- **`.runtimeMemory(mb)` / `.runtime_memory(mb)`** — the memory **floor** of the image (the [fork floor](#sizing-a-forks-memory) described above). Defaults to 1 GB. Forks can run at this or higher; raise it only for images whose services auto-start heavy at boot.
+This only affects the build. The resulting image is unchanged — you size the actual sandbox when you create it, via `memoryMB`:
<CodeGroup>
```typescript TypeScript
-// 8 GB to build (compiles a big toolchain) but a normal 1 GB floor for forks
+// 8 GB to build…
const image = Image.base()
.aptInstall(['build-essential', 'cmake'])
.runCommands('make -j')
.builderMemory(8192);
+
+// …but the sandbox runs at whatever you ask for
+const sandbox = await Sandbox.create({ image, memoryMB: 4096 });
```
```python Python
@@ -114,11 +116,12 @@ image = (
.run_commands("make -j")
.builder_memory(8192)
)
+sandbox = await Sandbox.create(image=image) # size via the HTTP API's memoryMB
```
</CodeGroup>
-Neither knob changes the cache key — they're resource parameters, not image content.
+`builderMemory` doesn't change the cache key — it's a build resource, not image content.
## Creating pre-built snapshots
@@ -315,8 +318,7 @@ The `Image` class provides a fluent, immutable API for defining sandbox environm
| `.addFile(path, content)` / `.add_file(path, content)` | Embed a file with inline content |
| `.addLocalFile(local, remote)` / `.add_local_file(local, remote)` | Read a local file into the image |
| `.addLocalDir(local, remote)` / `.add_local_dir(local, remote)` | Read a local directory into the image |
-| `.builderMemory(mb)` / `.builder_memory(mb)` | RAM for the build phase (does not pin the output floor) |
-| `.runtimeMemory(mb)` / `.runtime_memory(mb)` | Memory floor of the resulting image (default 1 GB) |
+| `.builderMemory(mb)` / `.builder_memory(mb)` | RAM for the build phase (default 4 GB; doesn't affect the resulting sandbox) |
| `.toJSON()` / `.to_dict()` | Return the image manifest |
| `.cacheKey()` / `.cache_key()` | Compute SHA-256 content hash |
diff --git a/internal/api/image_builder.go b/internal/api/image_builder.go
index 999591a8..cf95f4fc 100644
--- a/internal/api/image_builder.go
+++ b/internal/api/image_builder.go
@@ -27,25 +27,27 @@ type ImageManifest struct {
// BuilderMemoryMB is the RAM given to the build VM while it runs the steps
// (apt/pip can be memory-hungry; the old 1 GB default OOM'd large builds).
// It does NOT pin the output: the finalize pass re-snapshots at
- // RuntimeMemoryMB. Default defaultBuilderMemoryMB.
+ // RuntimeMemoryMB. Default defaultBuilderMemoryMB. Exposed in the SDKs as
+ // .builderMemory().
BuilderMemoryMB int `json:"builderMemoryMB,omitempty"`
// RuntimeMemoryMB is the memory floor of the OUTPUT image — the RAM the
- // finalize VM is cold-booted + savevm'd at. Forks of this image can't run
- // below it (a warm savevm can't shrink past its running size) but can hotplug
- // up. Default defaultRuntimeMemoryMB (= today's behavior). Raise it only for
- // images whose services auto-start heavy at boot.
+ // finalize VM is cold-booted + savevm'd at. Forks can't run below it (a warm
+ // savevm can't shrink past its running size) but can hotplug up. Defaults to
+ // defaultRuntimeMemoryMB (1 GB); callers size the actual sandbox at create
+ // time via memoryMB. NOT exposed in the SDKs — an advanced/raw-manifest knob
+ // for images whose services auto-start heavy at boot.
RuntimeMemoryMB int `json:"runtimeMemoryMB,omitempty"`
}
const (
- // defaultBuilderMemoryMB is the build-phase RAM. Generous so common
+ // defaultBuilderMemoryMB is the build-phase RAM. Enough that common
// apt/pip/npm builds don't OOM; safe because it never pins the output (see
// the finalize pass in buildImage).
- defaultBuilderMemoryMB = 8192
+ defaultBuilderMemoryMB = 4096
- // defaultRuntimeMemoryMB is the output image's memory floor. Kept at the
- // historical 1 GB so existing fork behavior is unchanged.
+ // defaultRuntimeMemoryMB is the output image's memory floor — the historical
+ // 1 GB, so every image forks down to 1 GB and scales up on demand.
defaultRuntimeMemoryMB = 1024
)
diff --git a/sdks/python/opencomputer/image.py b/sdks/python/opencomputer/image.py
index 6a69e4a5..93c0febb 100644
--- a/sdks/python/opencomputer/image.py
+++ b/sdks/python/opencomputer/image.py
@@ -47,12 +47,10 @@ class Image:
_base: str = "base"
_steps: tuple[ImageStep, ...] = field(default_factory=tuple)
- # RAM for the build phase (apt/pip). 0 = server default (generous). Does not
- # pin the output image — the server re-snapshots at the runtime floor.
+ # RAM for the build phase (apt/pip). 0 = server default. Does not pin the
+ # output image — the server re-snapshots at the default 1 GB floor, and you
+ # size the actual sandbox at create time via memory_mb.
_builder_memory_mb: int = 0
- # Memory floor of the OUTPUT image. 0 = server default (1 GB). Forks can't run
- # below this but can scale up. Raise only for images with heavy boot services.
- _runtime_memory_mb: int = 0
@classmethod
def base(cls) -> Image:
@@ -163,14 +161,10 @@ class Image:
def builder_memory(self, mb: int) -> Image:
"""Set the RAM (MB) for the build phase. Use this when a build OOMs at the
- default (e.g. heavy ``apt``/``pip``). Does not affect the output's floor."""
+ default 4 GB (e.g. heavy ``apt``/``pip``/``npm``). Does not affect the
+ resulting image's memory — size the sandbox at create time via ``memory_mb``."""
return replace(self, _builder_memory_mb=mb)
- def runtime_memory(self, mb: int) -> Image:
- """Set the memory floor (MB) of the resulting image. Forks can't run below
- it. Defaults to 1 GB; raise only for images whose services auto-start heavy."""
- return replace(self, _runtime_memory_mb=mb)
-
def to_dict(self) -> dict[str, Any]:
"""Returns the manifest as a plain dict (for JSON serialization)."""
d: dict[str, Any] = {
@@ -179,8 +173,6 @@ class Image:
}
if self._builder_memory_mb > 0:
d["builderMemoryMB"] = self._builder_memory_mb
- if self._runtime_memory_mb > 0:
- d["runtimeMemoryMB"] = self._runtime_memory_mb
return d
def cache_key(self) -> str:
diff --git a/sdks/typescript/src/image.ts b/sdks/typescript/src/image.ts
index 745c3cf5..31ef543d 100644
--- a/sdks/typescript/src/image.ts
+++ b/sdks/typescript/src/image.ts
@@ -10,13 +10,10 @@ export interface ImageStep {
export interface ImageManifest {
base: string;
steps: ImageStep[];
- /** RAM (MB) for the build phase (apt/pip). Omit for the server default
- * (generous). Does NOT pin the output — the server re-snapshots at the floor. */
+ /** RAM (MB) for the build phase (apt/pip). Omit for the server default. Does
+ * NOT pin the output — the server re-snapshots at the default 1 GB floor, and
+ * you size the actual sandbox at create time via memoryMB. */
builderMemoryMB?: number;
- /** Memory floor (MB) of the output image. Omit for the server default (1 GB).
- * Forks can't run below it but can scale up. Raise only for images with heavy
- * boot-time services. */
- runtimeMemoryMB?: number;
}
/**
@@ -138,20 +135,13 @@ export class Image {
/**
* Set the RAM (MB) for the build phase. Use this when a build OOMs at the
- * default (e.g. heavy `apt`/`pip`). Does not affect the output image's floor.
+ * default 4 GB (e.g. heavy `apt`/`pip`/`npm`). Does not affect the resulting
+ * image's memory — size the sandbox at create time via `memoryMB`.
*/
builderMemory(mb: number): Image {
return new Image({ ...this.manifest, builderMemoryMB: mb });
}
- /**
- * Set the memory floor (MB) of the resulting image. Forks can't run below it.
- * Defaults to 1 GB; raise only for images whose services auto-start heavy.
- */
- runtimeMemory(mb: number): Image {
- return new Image({ ...this.manifest, runtimeMemoryMB: mb });
- }
-
/**
* Returns the manifest as a plain object (for JSON serialization).
*/