Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(ci): pin Daytona snapshot ensure to the live 4/8/10 quota (#5897)
Wolf Mermelstein2c193bd4f87d
diff --git a/.github/workflows/ensure_daytona_snapshot.yml b/.github/workflows/ensure_daytona_snapshot.ymlindex 39fbac0ed0..ced66a2829 100644--- a/.github/workflows/ensure_daytona_snapshot.yml+++ b/.github/workflows/ensure_daytona_snapshot.yml@@ -12,6 +12,7 @@ name: Ensure Daytona Snapshotpaths:- crates/agent_harness/container/**- crates/agent_harness/justfile+ - crates/agent_harness/sandbox_sizes.json- nix/cloud-storage.nix- tooling/xtask/crates/xtask_workflows/src/workflows/ensure_daytona_snapshot.rs- '.github/workflows/ensure_daytona_snapshot.yml'@@ -21,6 +22,7 @@ name: Ensure Daytona Snapshotpaths:- crates/agent_harness/container/**- crates/agent_harness/justfile+ - crates/agent_harness/sandbox_sizes.json- nix/cloud-storage.nix- tooling/xtask/crates/xtask_workflows/src/workflows/ensure_daytona_snapshot.rs- '.github/workflows/ensure_daytona_snapshot.yml'@@ -61,9 +63,9 @@ jobs:shell: bashenv:DAYTONA_API_KEY: ${{ secrets.DAYTONA_API_KEY }}- DAYTONA_SNAPSHOT_CPU: '8'- DAYTONA_SNAPSHOT_MEMORY: '16'- DAYTONA_SNAPSHOT_DISK: '96'+ DAYTONA_SNAPSHOT_CPU: '4'+ DAYTONA_SNAPSHOT_MEMORY: '8'+ DAYTONA_SNAPSHOT_DISK: '10'publish-image:if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repositoryname: Publish sandbox image to GHCRdiff --git a/apps/web/src/features/block-agent/ui/SandboxSizeSelector.tsx b/apps/web/src/features/block-agent/ui/SandboxSizeSelector.tsxindex e4a6d8c2df..4c449554a8 100644--- a/apps/web/src/features/block-agent/ui/SandboxSizeSelector.tsx+++ b/apps/web/src/features/block-agent/ui/SandboxSizeSelector.tsx@@ -1,19 +1,25 @@import CaretDown from '@phosphor-icons/core/regular/caret-down.svg?component-solid';+import sizes from '@sandbox-sizes';import { Dropdown } from '@ui';import { For } from 'solid-js';/** Named compute tier for a managed coding-agent sandbox. */export type SandboxSize = 'small' | 'default' | 'large';-const TIERS: {- id: SandboxSize;- label: string;- detail: string;-}[] = [- { id: 'small', label: 'Small', detail: '2 vCPU · 4 GiB · 96 GiB' },- { id: 'default', label: 'Default', detail: '8 vCPU · 16 GiB · 96 GiB' },- { id: 'large', label: 'Large', detail: '16 vCPU · 32 GiB · 96 GiB' },-];+const TIER_LABELS: Record<SandboxSize, string> = {+ small: 'Small',+ default: 'Default',+ large: 'Large',+};++const TIERS = (Object.keys(TIER_LABELS) as SandboxSize[]).map((id) => {+ const { cpu, memoryGib, diskGib } = sizes[id];+ return {+ id,+ label: TIER_LABELS[id],+ detail: `${cpu} vCPU · ${memoryGib} GiB · ${diskGib} GiB`,+ };+});export interface SandboxSizeSelectorProps {size: SandboxSize;diff --git a/apps/web/src/lib/service-clients/service-agent-harness/generated/schemas/sandboxSize.ts b/apps/web/src/lib/service-clients/service-agent-harness/generated/schemas/sandboxSize.tsindex 9d4ffd1dea..ae2490a5be 100644--- a/apps/web/src/lib/service-clients/service-agent-harness/generated/schemas/sandboxSize.ts+++ b/apps/web/src/lib/service-clients/service-agent-harness/generated/schemas/sandboxSize.ts@@ -8,8 +8,8 @@/*** Named compute tier for a managed sandbox.-Disk is always 96 GiB; CPU and RAM vary. The API and database store the-name, never raw resource integers.+The API and database store the name. CPU, RAM, and disk live in+`crates/agent_harness/sandbox_sizes.json`.*/export type SandboxSize = (typeof SandboxSize)[keyof typeof SandboxSize];diff --git a/apps/web/src/lib/service-clients/service-agent-harness/openapi.json b/apps/web/src/lib/service-clients/service-agent-harness/openapi.jsonindex c319cc9995..e24c0bf4ac 100644--- a/apps/web/src/lib/service-clients/service-agent-harness/openapi.json+++ b/apps/web/src/lib/service-clients/service-agent-harness/openapi.json@@ -913,7 +913,7 @@},"SandboxSize": {"type": "string",- "description": "Named compute tier for a managed sandbox.\n\nDisk is always 96 GiB; CPU and RAM vary. The API and database store the\nname, never raw resource integers.",+ "description": "Named compute tier for a managed sandbox.\n\nThe API and database store the name. CPU, RAM, and disk live in\n`crates/agent_harness/sandbox_sizes.json`.","enum": ["small", "default", "large"]},"SandboxSizeBody": {diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.jsonindex 2306e05c99..fa63a9d539 100644--- a/apps/web/tsconfig.json+++ b/apps/web/tsconfig.json@@ -1,7 +1,8 @@{"include": ["./src/**/*",- "./src/lib/core/component/Emoji/cldr-tags.json"+ "./src/lib/core/component/Emoji/cldr-tags.json",+ "../../crates/agent_harness/sandbox_sizes.json"],"exclude": ["./tests/**/*",@@ -43,6 +44,9 @@"@types/facebook-pixel"],"paths": {+ "@sandbox-sizes": [+ "../../crates/agent_harness/sandbox_sizes.json"+ ],"loro-crdt": ["../../node_modules/loro-crdt"],diff --git a/crates/agent_harness/justfile b/crates/agent_harness/justfileindex bc649cca28..68489b2ec4 100644--- a/crates/agent_harness/justfile+++ b/crates/agent_harness/justfile@@ -23,12 +23,10 @@ set dotenv-load := true# repository in Namespace's nscr.io workspace registry.image_name := env_var_or_default("AGENT_HARNESS_IMAGE", "macro-agent-harness")-# Default sandbox size baked into the snapshot. CI exports the same three-# values. Live Daytona orgs still on the 4/8/10 per-sandbox cap cannot-# create this until [email protected] raises the limit.-snapshot_cpu := env_var_or_default("DAYTONA_SNAPSHOT_CPU", "8")-snapshot_memory := env_var_or_default("DAYTONA_SNAPSHOT_MEMORY", "16")-snapshot_disk := env_var_or_default("DAYTONA_SNAPSHOT_DISK", "96")+# Snapshot bake size from sandbox_sizes.json. Override with DAYTONA_SNAPSHOT_*.+snapshot_cpu := env_var_or_default("DAYTONA_SNAPSHOT_CPU", `jq -r .snapshot.cpu sandbox_sizes.json`)+snapshot_memory := env_var_or_default("DAYTONA_SNAPSHOT_MEMORY", `jq -r .snapshot.memoryGib sandbox_sizes.json`)+snapshot_disk := env_var_or_default("DAYTONA_SNAPSHOT_DISK", `jq -r .snapshot.diskGib sandbox_sizes.json`)# Cheap for the agent to answer, and it proves the repo actually cloned.default_prompt := "list the files in the repo root, then stop"diff --git a/crates/agent_harness/sandbox_sizes.json b/crates/agent_harness/sandbox_sizes.jsonnew file mode 100644index 0000000000..d3b0722364--- /dev/null+++ b/crates/agent_harness/sandbox_sizes.json@@ -0,0 +1,6 @@+{+ "small": { "cpu": 2, "memoryGib": 4, "diskGib": 24 },+ "default": { "cpu": 4, "memoryGib": 8, "diskGib": 96 },+ "large": { "cpu": 8, "memoryGib": 16, "diskGib": 128 },+ "snapshot": { "cpu": 4, "memoryGib": 8, "diskGib": 10 }+}diff --git a/crates/agent_harness/src/domain/sandbox.rs b/crates/agent_harness/src/domain/sandbox.rsindex 1c0f75abde..c00dea7ddd 100644--- a/crates/agent_harness/src/domain/sandbox.rs+++ b/crates/agent_harness/src/domain/sandbox.rs@@ -1,22 +1,60 @@//! Compute resources for a [`SandboxSize`].+//!+//! Named-tier CPU, RAM, and disk come from [`SANDBOX_SIZES_JSON`]. Daytona+//! snapshot creates inherit [`snapshot`] until the org quota can take the+//! product default disk.++use std::sync::OnceLock;use agent_session::domain::model::SandboxSize;+use serde::Deserialize;#[cfg(test)]mod test;+/// Checked-in size table. UI, justfile, and CI read the same file.+pub(crate) const SANDBOX_SIZES_JSON: &str =+ include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/sandbox_sizes.json"));++#[derive(Debug, Deserialize)]+#[serde(rename_all = "camelCase")]+struct Quota {+ cpu: u32,+ memory_gib: u32,+ disk_gib: u32,+}++#[derive(Debug, Deserialize)]+struct SizeTable {+ small: Quota,+ default: Quota,+ large: Quota,+ snapshot: Quota,+}++fn table() -> &'static SizeTable {+ static TABLE: OnceLock<SizeTable> = OnceLock::new();+ TABLE.get_or_init(|| {+ serde_json::from_str(SANDBOX_SIZES_JSON).expect("sandbox_sizes.json should parse")+ })+}++fn resources_from(quota: &Quota) -> SandboxResources {+ SandboxResources {+ cpu: quota.cpu,+ memory_gib: quota.memory_gib,+ disk_gib: quota.disk_gib,+ }+}+/// CPU, RAM, and disk for one sandbox size.-///-/// Disk is 96 GiB for every tier so a live session can raise CPU/RAM in place-/// without a disk migrate. Growing disk requires a stop; shrinking it is not-/// supported.#[derive(Debug, Clone, Copy, PartialEq, Eq)]pub struct SandboxResources {/// vCPU cores.pub cpu: u32,/// RAM in GiB.pub memory_gib: u32,- /// Disk in GiB. Constant across tiers.+ /// Disk in GiB.pub disk_gib: u32,}@@ -38,33 +76,28 @@ pub enum SandboxResizeEffect {Unsupported,}-/// Resources for `size`. Disk is always 96 GiB.+/// Resources for `size` from [`SANDBOX_SIZES_JSON`].#[must_use]pub fn resources(size: SandboxSize) -> SandboxResources {- match size {- SandboxSize::Small => SandboxResources {- cpu: 2,- memory_gib: 4,- disk_gib: 96,- },- SandboxSize::Default => SandboxResources {- cpu: 8,- memory_gib: 16,- disk_gib: 96,- },- SandboxSize::Large => SandboxResources {- cpu: 16,- memory_gib: 32,- disk_gib: 96,- },- }+ let table = table();+ resources_from(match size {+ SandboxSize::Small => &table.small,+ SandboxSize::Default => &table.default,+ SandboxSize::Large => &table.large,+ })+}++/// Daytona snapshot bake size from [`SANDBOX_SIZES_JSON`].+#[must_use]+pub fn snapshot() -> SandboxResources {+ resources_from(&table().snapshot)}/// CPU/RAM comparison used by managers that can resize a live container.///-/// Disk is ignored: named tiers never change disk, and shrinking it is not-/// supported. Spawn uses this against a snapshot's live CPU/RAM because-/// `POST /sandbox` with a snapshot cannot set resources.+/// Disk is ignored: Daytona resize does not send disk, so a live session keeps+/// the snapshot's disk. Spawn uses this against a snapshot's live CPU/RAM+/// because `POST /sandbox` with a snapshot cannot set resources.#[must_use]pub fn resize_effect(from: SandboxSize, to: SandboxSize) -> SandboxResizeEffect {resize_effect_from_resources(resources(from), resources(to))diff --git a/crates/agent_harness/src/domain/sandbox/test.rs b/crates/agent_harness/src/domain/sandbox/test.rsindex 706ad4239f..86130b3235 100644--- a/crates/agent_harness/src/domain/sandbox/test.rs+++ b/crates/agent_harness/src/domain/sandbox/test.rs@@ -1,22 +1,32 @@use super::*;#[test]-fn disk_is_96_gib_for_every_tier() {- for size in [SandboxSize::Small, SandboxSize::Default, SandboxSize::Large] {- assert_eq!(resources(size).disk_gib, 96);+fn resources_come_from_sandbox_sizes_json() {+ let table: serde_json::Value =+ serde_json::from_str(SANDBOX_SIZES_JSON).expect("sandbox_sizes.json should parse");+ for (size, key) in [+ (SandboxSize::Small, "small"),+ (SandboxSize::Default, "default"),+ (SandboxSize::Large, "large"),+ ] {+ let row = &table[key];+ assert_eq!(+ resources(size),+ SandboxResources {+ cpu: row["cpu"].as_u64().unwrap() as u32,+ memory_gib: row["memoryGib"].as_u64().unwrap() as u32,+ disk_gib: row["diskGib"].as_u64().unwrap() as u32,+ }+ );}}#[test]-fn default_is_eight_cpu_sixteen_gib() {- assert_eq!(- resources(SandboxSize::Default),- SandboxResources {- cpu: 8,- memory_gib: 16,- disk_gib: 96,- }- );+fn snapshot_matches_default_cpu_and_ram() {+ let snapshot = snapshot();+ let default = resources(SandboxSize::Default);+ assert_eq!(snapshot.cpu, default.cpu);+ assert_eq!(snapshot.memory_gib, default.memory_gib);}#[test]@@ -49,21 +59,29 @@ fn cpu_ram_increases_are_in_place_and_decreases_need_a_restart() {#[test]fn live_quotas_that_are_not_named_tiers_still_pick_in_place_or_restart() {- let snapshot = SandboxResources {- cpu: 4,- memory_gib: 8,- disk_gib: 10,+ let smaller = SandboxResources {+ cpu: resources(SandboxSize::Small).cpu,+ memory_gib: resources(SandboxSize::Small).memory_gib,+ disk_gib: snapshot().disk_gib,};assert_eq!(- resize_effect_from_resources(snapshot, resources(SandboxSize::Default)),+ resize_effect_from_resources(smaller, resources(SandboxSize::Default)),SandboxResizeEffect::InPlace);assert_eq!(- resize_effect_from_resources(resources(SandboxSize::Default), snapshot),+ resize_effect_from_resources(resources(SandboxSize::Default), smaller),SandboxResizeEffect::Restart);assert_eq!(- resize_effect_from_resources(snapshot, snapshot),+ resize_effect_from_resources(smaller, smaller),+ SandboxResizeEffect::NoOp+ );+}++#[test]+fn default_is_a_cpu_ram_noop_against_the_snapshot() {+ assert_eq!(+ resize_effect_from_resources(snapshot(), resources(SandboxSize::Default)),SandboxResizeEffect::NoOp);}diff --git a/crates/agent_harness/src/outbound/daytona/manager.rs b/crates/agent_harness/src/outbound/daytona/manager.rsindex 9609497fab..43c53355ce 100644--- a/crates/agent_harness/src/outbound/daytona/manager.rs+++ b/crates/agent_harness/src/outbound/daytona/manager.rs@@ -255,7 +255,7 @@ impl DaytonaContainerManager {id: &DaytonaSandboxId,size: agent_session::domain::model::SandboxSize,) -> Result<()> {- let (cpu, memory, _) = self+ let (cpu, memory, disk) = self.client.resources(id.as_str()).await@@ -269,7 +269,7 @@ impl DaytonaContainerManager {let current = SandboxResources {cpu,memory_gib: memory,- disk_gib: 96,+ disk_gib: disk.unwrap_or(0),};let next = resources(size);let kind = resize_effect_from_resources(current, next);@@ -418,7 +418,7 @@ impl ContainerManager for DaytonaContainerManager {"session {session} has no sandbox to resize")));};- let (cpu, memory, _) = self+ let (cpu, memory, disk) = self.client.resources(id.as_str()).await@@ -432,7 +432,7 @@ impl ContainerManager for DaytonaContainerManager {let current = SandboxResources {cpu,memory_gib: memory,- disk_gib: 96,+ disk_gib: disk.unwrap_or(0),};let next = resources(size);self.apply_resize(&id, next, resize_effect_from_resources(current, next))diff --git a/crates/agent_session/src/domain/sandbox_size.rs b/crates/agent_session/src/domain/sandbox_size.rsindex 10989c0979..1b895e88ee 100644--- a/crates/agent_session/src/domain/sandbox_size.rs+++ b/crates/agent_session/src/domain/sandbox_size.rs@@ -8,17 +8,17 @@ mod test;/// Named compute tier for a managed sandbox.///-/// Disk is always 96 GiB; CPU and RAM vary. The API and database store the-/// name, never raw resource integers.+/// The API and database store the name. CPU, RAM, and disk live in+/// `crates/agent_harness/sandbox_sizes.json`.#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]#[serde(rename_all = "camelCase")]pub enum SandboxSize {- /// 2 vCPU / 4 GiB RAM / 96 GiB disk.+ /// Smallest named tier.Small,- /// 8 vCPU / 16 GiB RAM / 96 GiB disk.+ /// Default named tier.#[default]Default,- /// 16 vCPU / 32 GiB RAM / 96 GiB disk.+ /// Largest named tier.Large,}diff --git a/docs/AGENT_SANDBOX_SIZE_PLAN.md b/docs/AGENT_SANDBOX_SIZE_PLAN.mddeleted file mode 100644index a97c705eb7..0000000000--- a/docs/AGENT_SANDBOX_SIZE_PLAN.md+++ /dev/null@@ -1,304 +0,0 @@-# Agent Sandbox Sizes (small / default / large)--## Status--Implemented. Named tiers, user default, in-place Daytona resize (hot up / cold down), and a size picker on the agent composer.--Disk is 96 GiB on every tier so a live session can hot-resize CPU/RAM without a disk migrate. Changing the picker resizes **this** sandbox and updates the user default for the next `@coder`.--## Problem--Macro Coder sessions always get one Daytona size, and that size is not chosen in product code. It is baked into the snapshot:--- `crates/agent_harness/justfile` `ensure-daytona` used to create `macro-agent-harness` with `--cpu 4 --memory 8 --disk 10`.-- The justfile still comments that 10GB disk was the account ceiling. That quota is now raised.-- `POST /sandbox` in `crates/agent_harness/src/outbound/daytona/client.rs` sends only `snapshot`, `env`, `labels`, and `autoStopInterval`. It does not send CPU, RAM, or disk.-- The Namespace provider hardcodes 2 vCPU / 4GB RAM and has no disk field.-- `SpawnContainer` carries `session_id` and `repo_url` only.-- `agent_session` stores model, harness, repo, and workspace, not sandbox size.-- Macro Coder sessions are opened by the mention trigger. `POST /agent-sessions` rejects managed bots. There is no UI or API for a user to pick a size.--The wanted product is three named tiers (`small`, `default`, `large`), with `default` being 8 vCPU / 16 GiB RAM / 96 GiB disk, and a way for a user to choose a tier that future `@coder` sessions actually use.--## Decisions--1. **Named tiers, not raw integers.** The domain type is `SandboxSize::{Small, Default, Large}`. UI and API never send `cpu` / `memory` / `disk`. Those numbers are a provider mapping owned by the harness domain.-2. **`default` is 8 / 16 / 96.** That is the new Macro Coder size. `small` and `large` are scaled off it (numbers below; confirm `large` against the live Daytona quota before shipping it).-3. **One snapshot, size after create.** Do not build three snapshots. Rebuild `macro-agent-harness` at the default resource profile (`--cpu 8 --memory 16 --disk 96`). Daytona returns 400 if `cpu` / `memory` / `disk` are sent on `POST /sandbox` with a snapshot, so spawn creates from the snapshot, waits for start, and applies the named tier with `POST /sandbox/{id}/resize` (hot if CPU/RAM only increase, cold if either decreases). Disk is never sent on resize. Namespace maps the same tier onto `virtual_cpu` / `memory_megabytes` at create time.-4. **Size is snapshotted onto the session at spawn and can be changed in place when the manager allows it.** CPU/RAM upgrades are in-place on a running Daytona sandbox. Downgrades stop, resize, and start it again. Disk never changes. Local Docker and Namespace report `Unsupported` (no in-place resize).-5. **User default drives mention spawn.** `@coder` has no settings chrome. The harness reads the mentioning user's default size (falling back to `default`) and writes it onto the new session before `spawn`.-6. **Sandbox size is not an `AgentAction`.** `AgentAction` is ACP (`prompt`, `set_model`, `compact`, `stop`). Size is harness/container policy. Do not send it to the agent. Use a dedicated settings endpoint for the user default, and a field on the session response for the size this session was spawned with.-7. **Every authenticated user may pick any tier.** No plan gating, no locks, no team-admin override, no extra receipts. `GET`/`PUT` the caller's own default; mention spawn already knows the sender. Handlers do not branch on who may use `large`.-8. **Policy lives in the harness domain; resize capability lives on the container-manager port.** Inbound parses the tier. Domain validates the name, resolves the user default, and puts it on `SpawnContainer`. Named size → CPU/RAM/disk is harness mapping. Whether an existing container can take that change (`NoOp` / `InPlace` / `Restart` / `Unsupported`) is `ContainerManager::resize_effect`. Domain closes/resumes from that effect and calls `resize(session, size)` with no kind argument. Adapters implement the effect and the resize. Hexagonal boundary: no Daytona/Namespace types in domain, no size policy in axum handlers or the web picker.--## Goals--- Every new Macro Coder sandbox is 8 vCPU / 16 GiB / 96 GiB unless the user picked `small` or `large`.-- `GET` session includes `sandboxSize`.-- A user can set their default size; the next `@coder` mention uses it.-- Unknown or raw resource payloads are rejected at the API boundary.-- Daytona and Namespace both honor the same three tiers.-- Existing sessions keep working: a NULL/missing size on old rows means `default` at the new resource mapping only for *new* spawns. Already-running sandboxes stay at whatever Daytona already gave them.--## Non-goals (v1)--- Recreating a sandbox to change size (Daytona CPU/RAM resize in place instead).-- Per-team or per-org size caps, plan gating, or paywalled `large`.-- Extra authorization beyond "the caller sets their own default."-- Billing, metering, or showing remaining Daytona quota in the UI.-- GPU tiers.-- Letting external (non-managed) agent runtimes declare a size. They bring their own machine.-- Putting a size picker in the `@` mention typeahead.-- Recreating a live sandbox when the user changes their default.--## Resource mapping--Units match Daytona: CPU cores, memory GiB, disk GiB.--| Tier | vCPU | RAM | Disk | Notes |-| --------- | ---- | --- | ---- | ------------------------------------------ |-| `small` | 2 | 4 | 96 | Cheap / short tasks |-| `default` | 8 | 16 | 96 | The new Macro Coder size |-| `large` | 16 | 32 | 96 | Same disk so live sessions can hot-resize |--Namespace create gets the same tier, mapped onto its shape (`virtual_cpu`, `memory_megabytes` = RAM GiB × 1024). It has no disk field today, so disk is Daytona-only until Namespace exposes one.--If the live Daytona quota cannot place `large`, ship `small` + `default` only and keep `Large` out of the public enum until it can.--## Product behavior--### New `@coder` mention--1. Trigger pipeline opens a managed session as it does today.-2. Harness loads the sender's default `SandboxSize`, or `Default`.-3. Session row is created with that size.-4. `spawn` passes the size to the container manager.-5. Daytona create omits resource fields. After the sandbox starts, spawn resizes CPU/RAM to the session tier (in-place if the snapshot is smaller, restart if it is larger). Disk stays at the snapshot's disk.--### User default--- Stored server-side in `user_agent_sandbox_size`, not in `localStorage` — mention spawn is backend-only and would ignore a browser preference.-- Any signed-in user can read and write **their own** row. All three sizes are available. No extra authz layer.-- New endpoint, not `POST /agent-sessions` (that route still rejects managed bots) and not `/control` (that route is ACP).-- Suggested shape:- - `GET /agent-sandbox-size` → `{ size: "small" | "default" | "large" }`- - `PUT /agent-sandbox-size` `{ size }` → same-- First-time users have no row; reads return `default`.--### Resume / idle stop--- Idle reaper still stops the sandbox; resume starts the same Daytona id.-- Do not re-apply size on resume. The box already has a size.-- Teardown + a brand-new session is the only v1 way to get a different size.--## Domain design--### `SandboxSize`--New domain enum in `crates/agent_harness` (owned there, not in `agent_session` ACP types):--```rust-pub enum SandboxSize {- Small,- Default,- Large,-}-```--- Serde/API: `"small" | "default" | "large"`.-- `Default` for `#[default]` and for missing DB values.-- `resources(self) -> SandboxResources { cpu, memory_gib, disk_gib }` is domain data, not an outbound DTO.--`agent_session` may store the enum as text on the row and echo it on `AgentSessionResponse`. It should not know Daytona field names.--### `SpawnContainer`--Add `size: SandboxSize`. Both Daytona and Namespace managers read it. Fakes in harness tests must too.--### Session row--Migration on `agent_session`:--```sql-ALTER TABLE agent_session- ADD COLUMN sandbox_size TEXT NOT NULL DEFAULT 'default'- CHECK (sandbox_size IN ('small', 'default', 'large'));-```--Existing rows become `default`. That label does **not** resize already-created Daytona sandboxes.--### User default row--New table, not a column on `"User"`:--```sql-CREATE TABLE user_agent_sandbox_size (- user_id TEXT PRIMARY KEY REFERENCES "User"("id") ON DELETE CASCADE,- sandbox_size TEXT NOT NULL- CHECK (sandbox_size IN ('small', 'default', 'large')),- modified_at TIMESTAMPTZ NOT NULL DEFAULT now()-);-```--Port: `AgentSandboxSizePreference` with `get(user) -> SandboxSize` and `set(user, size)`. Missing row → `Default`. The authenticated user is the `user_id`; do not add role checks, receipts, or per-tier permission.--### Authorization--None beyond the existing session view extractor and "this is my user id." Every user can pick `small`, `default`, or `large`. Spawn uses the observed mention sender; it must not take a size from the message body.--## Provider mapping--### Daytona--`CreateSandboxRequest` gains:--```rust-cpu: u32,-memory: u32, // GiB-disk: u32, // GiB-```--`configuration_parameters` sends `snapshot`, `env`, `labels`, and `auto_stop_interval: 0` only. Daytona rejects `cpu` / `memory` / `disk` on snapshot creates (HTTP 400: "Cannot specify Sandbox resources when using a snapshot"). Size is applied after start via `POST /sandbox/{id}/resize` with `cpu` and `memory` only.--Snapshot create in `justfile` / `ensure-daytona` is `--cpu 8 --memory 16 --disk 96` so a `default` spawn is a no-op after create, `large` is an in-place resize, and `small` is a restart resize. Rebuild the snapshot (delete + create); `snapshot create` will not replace an existing name.--Verify with a throwaway sandbox: create from the snapshot with no resource fields, wait until started, stay inside the org per-sandbox cap, shrink while stopped, then raise CPU/RAM in place without sending `disk`, and confirm disk is unchanged. Always delete the sandbox.--### Namespace--Same idea as Daytona: create-time resources from the tier, not a hardcoded shape.--Replace--```rust-virtual_cpu: 2,-memory_megabytes: 4096,-```--with the mapped `virtual_cpu` and `memory_megabytes` for `SpawnContainer.size`. Namespace's `ShapeRequest` has no disk field, so do not invent one. If Namespace adds disk later, thread `disk_gib` through the same mapping.--### coding-agent-worker--Out of scope unless it is still used to boot Macro Coder. Production harness is `crates/agent_harness`. Do not silently fork a second size table there.--## API / SDK--- `AgentSessionResponse.sandboxSize`: `"small" | "default" | "large"`.-- New user-default routes on the agent harness service (same service that already owns managed sessions).-- OpenAPI in `agent_session` / `agent_harness_service` swagger, then `just coverage` / add-sdk-endpoint skill so `packages/sdk` and the web generated client pick it up.-- Do **not** add `sandboxSize` to `CreateAgentSessionRequest` in v1. That route is for external runtimes and rejects managed bots. Mention spawn is not that route.--## UI--Small composer control, same family as Macro AI's `ModelSelector` — not a header setting, not in the `@` mention typeahead.--`AgentInput` today is a `Surface` with the editor and a send/stop button in the bottom-right. Add a ghost `Dropdown` to the left of send, mirroring `ChatInput`'s right-controls cluster.--### Closed--```-┌──────────────────────────────────────────────────────┐-│ Message the agent │-│ [Default ▾] (send) │-└──────────────────────────────────────────────────────┘-```--Trigger: `Dropdown.Trigger` `variant="ghost"` `size="sm"`, `text-xs`, caret, no CPU icon required. Label is the **user default** (`Small` / `Default` / `Large`), not raw resources.--When the editor wraps past one line, the chip stays bottom-right with send, same as ChatInput.--### Open--```- ┌──────────────────────────┐- │ Small │- │ 2 vCPU · 4 GB · 20 GB │- │ ✓ Default │- │ 8 vCPU · 16 GB · 96 GB │- │ Large │- │ 16 vCPU · 32 GB · 200 GB │- │ │- │ Applies to new @coder │- │ sessions │- └──────────────────────────┘-┌──────────────────────────────────────────────────────┐-│ Message the agent │-│ [Default ▾] (send) │-└──────────────────────────────────────────────────────┘-```--All three rows are always enabled. No lock icons, no paywall, no "unavailable." Checkmark on the current user default.--Footer copy is required: picking a size does not resize the open sandbox. `PUT /agent-sandbox-size`, toast on success ("New @coder sessions will use Large").--If this session's snapshotted size differs from the user default, the trigger can stay as the default (what you will get next) rather than the current session. Optional muted line under the footer: `This session: Default`. Skip that if it feels noisy; the session response still has `sandboxSize` for later.--### Component split--- `apps/web/src/features/block-agent/ui/SandboxSizeSelector.tsx` — pure: `size`, `onSelect`, options hardcoded. Reuse `@ui` `Dropdown` like `ModelSelector`.-- `AgentInput` grows an optional `size` / `onSizeSelect` slot in the right-controls cluster. Keep the ui/ component free of queries.-- `AgentComposer` loads `GET /agent-sandbox-size` (fallback `default`) and `PUT`s on select.--No picker on `AgentSplitHeader`. No mention-typeahead control.--## Phasing--### 1. Default size bump (can ship alone)--- Snapshot flags → 8 / 16 / 96.-- Daytona create omits `cpu`/`memory`/`disk`.-- Tests: Daytona create JSON omits resource fields; resize omits `disk`; snapshot justfile comment about the 10GB ceiling is removed.-- No UI. Every new sandbox is `default`.--### 2. Domain + persistence + API--- `SandboxSize` enum, `SpawnContainer.size`, session column, user-default table.-- Mention `open` reads the user default.-- `GET`/`PUT /agent-sandbox-size`, session response field.-- Domain tests: missing preference → `Default`; `PUT` then mention uses the new size; unknown size → 422; outbound mapping for all three tiers on both providers.--### 3. UI picker--- `SandboxSizeSelector` on `AgentInput`, wired from `AgentComposer`.-- Generated client from phase 2.-- Footer copy + toast that this session does not resize.--### 4. Later (not this plan)--- Daytona `resize` for CPU/RAM on a live session (disk grow-only).-- Team default.-- "Restart this session at a new size" (teardown + new sandbox; loses the live workspace unless we snapshot first).--## Testing--- `cargo test -p agent_harness` for spawn mapping, preference fallback, and Daytona request body.-- `cargo test -p agent_session` for the new column on create/get fixtures.-- SQLX: `just prepare_db` after the migration, from the repo root, with `SQLX_OFFLINE` unset.-- Web: `SandboxSizeSelector` test that every tier is enabled; composer test that select calls `PUT` and does not call session `/control`.-- Manual: one real Daytona create per tier against the quota (phase 1 spike for override; phase 2 for `small` vs `default`).--## Risks--- **Snapshot create rejects resource fields (HTTP 400).** Mitigated by inheriting snapshot quotas on create and applying the named tier with resize.-- **`POST /sandbox/{id}/resize` 404s with `Cannot POST` when the route is not registered on this API.** Daytona documents resize as available to all organizations. The client maps that 404 to `ResizeNotEnabled`. A missing sandbox 404s with "not found" instead.-- **Live per-sandbox cap is 4 vCPU / 8 GiB / 10 GiB.** `POST /snapshots` with `--cpu 8 --memory 16 --disk 96` returns 400: "CPU request 8 exceeds maximum allowed per sandbox (4)". Ask Daytona to raise per-sandbox limits to at least 16 / 32 / 96 (`large`) before rebuilding `macro-agent-harness`. Do not delete the live 4/8/10 snapshot until that create would succeed.-- **`large` exceeds quota.** Keep it out of the public enum until a create succeeds.-- **Users think the picker resizes the open session.** Header copy + toast. Size on the session response is the spawned size, not the pending default.-- **Mention already spawned before the UI is visible.** That is why the picker edits the *next* session's default, not the current sandbox.-- **Namespace disk.** Document that `small`/`large` on Namespace only change CPU/RAM.--## Files (expected)--- `crates/agent_harness/justfile` — snapshot resources-- `crates/agent_harness/src/domain/ports.rs` — `ContainerManager::resize_effect` + `resize` without a kind argument-- `crates/agent_harness/src/domain/sandbox.rs` — named size → CPU/RAM/disk; in-place vs restart comparison-- `crates/agent_harness/src/domain/service.rs` — resolve user default on `open`-- `crates/agent_harness/src/outbound/daytona/client.rs` — create omits resources; resize sends `cpu`/`memory`-- `crates/agent_harness/src/outbound/namespace/client.rs` — shape from tier-- `crates/agent_session/src/domain/model.rs` + postgres outbound — `sandbox_size` column-- `crates/macro_db_client/migrations/` — session column + `user_agent_sandbox_size`-- `crates/agent_session/src/inbound/axum_router.rs` — response field; new default-size handlers (or a small harness inbound module)-- `apps/web/src/features/block-agent/ui/SandboxSizeSelector.tsx` — dropdown-- `apps/web/src/features/block-agent/ui/AgentInput.tsx` — right-controls slot next to send-- `apps/web/src/features/block-agent/component/AgentComposer.tsx` — GET/PUT default size-- Generated OpenAPI / SDK clients after the new routesdiff --git a/packages/sdk/generated/agent-harness/types.gen.ts b/packages/sdk/generated/agent-harness/types.gen.tsindex 7b025eb64c..99063f6488 100644--- a/packages/sdk/generated/agent-harness/types.gen.ts+++ b/packages/sdk/generated/agent-harness/types.gen.ts@@ -315,8 +315,8 @@ export type RenameAgentSessionRequest = {/*** Named compute tier for a managed sandbox.*- * Disk is always 96 GiB; CPU and RAM vary. The API and database store the- * name, never raw resource integers.+ * The API and database store the name. CPU, RAM, and disk live in+ * `crates/agent_harness/sandbox_sizes.json`.*/export type SandboxSize = 'small' | 'default' | 'large';diff --git a/packages/sdk/specs/agent-harness.json b/packages/sdk/specs/agent-harness.jsonindex c319cc9995..e24c0bf4ac 100644--- a/packages/sdk/specs/agent-harness.json+++ b/packages/sdk/specs/agent-harness.json@@ -913,7 +913,7 @@},"SandboxSize": {"type": "string",- "description": "Named compute tier for a managed sandbox.\n\nDisk is always 96 GiB; CPU and RAM vary. The API and database store the\nname, never raw resource integers.",+ "description": "Named compute tier for a managed sandbox.\n\nThe API and database store the name. CPU, RAM, and disk live in\n`crates/agent_harness/sandbox_sizes.json`.","enum": ["small", "default", "large"]},"SandboxSizeBody": {diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/ensure_daytona_snapshot.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/ensure_daytona_snapshot.rsindex 3d73d69740..bdfe6871b9 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/ensure_daytona_snapshot.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/ensure_daytona_snapshot.rs@@ -13,6 +13,22 @@ use gh_workflow::{use crate::workflows::{runners, steps, vars};+const SANDBOX_SIZES_JSON: &str = include_str!(concat!(+ env!("CARGO_MANIFEST_DIR"),+ "/../../../../crates/agent_harness/sandbox_sizes.json"+));++fn snapshot_quota() -> (String, String, String) {+ let sizes: serde_json::Value =+ serde_json::from_str(SANDBOX_SIZES_JSON).expect("sandbox_sizes.json should parse");+ let snapshot = &sizes["snapshot"];+ (+ snapshot["cpu"].to_string(),+ snapshot["memoryGib"].to_string(),+ snapshot["diskGib"].to_string(),+ )+}+#[cfg(test)]mod test;@@ -36,10 +52,11 @@ fn image_source_pull_request() -> PullRequest {pr}-fn image_source_paths() -> [xtask_paths::RepoGlob<'static>; 5] {+fn image_source_paths() -> [xtask_paths::RepoGlob<'static>; 6] {[xtask_paths::repo_glob!("crates/agent_harness/container/**"),xtask_paths::repo_glob!("crates/agent_harness/justfile"),+ xtask_paths::repo_glob!("crates/agent_harness/sandbox_sizes.json"),xtask_paths::repo_glob!("nix/cloud-storage.nix"),xtask_paths::repo_glob!("tooling/xtask/crates/xtask_workflows/src/workflows/ensure_daytona_snapshot.rs"@@ -69,6 +86,7 @@ pub fn ensure_daytona_snapshot() -> Workflow {}fn ensure_snapshot() -> Job {+ let (cpu, memory, disk) = snapshot_quota();Job::default().name("Ensure macro-agent-harness snapshot").runs_on(runners::Runner::Small.to_string())@@ -92,9 +110,9 @@ fn ensure_snapshot() -> Job {"#}).shell("bash").add_env(("DAYTONA_API_KEY", vars::DAYTONA_API_KEY))- .add_env(("DAYTONA_SNAPSHOT_CPU", "8"))- .add_env(("DAYTONA_SNAPSHOT_MEMORY", "16"))- .add_env(("DAYTONA_SNAPSHOT_DISK", "96")),+ .add_env(("DAYTONA_SNAPSHOT_CPU", cpu))+ .add_env(("DAYTONA_SNAPSHOT_MEMORY", memory))+ .add_env(("DAYTONA_SNAPSHOT_DISK", disk)),)}diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/ensure_daytona_snapshot/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/ensure_daytona_snapshot/test.rsindex 0f9dd33ec3..dac9e3e483 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/ensure_daytona_snapshot/test.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/ensure_daytona_snapshot/test.rs@@ -66,11 +66,21 @@ fn daytona_job_stays_on_the_small_runner_and_skips_prs() {}#[test]-fn daytona_job_requests_the_default_snapshot_size() {+fn daytona_job_requests_the_json_snapshot_size() {let yaml = rendered();- assert!(yaml.contains("DAYTONA_SNAPSHOT_CPU: '8'"), "{yaml}");- assert!(yaml.contains("DAYTONA_SNAPSHOT_MEMORY: '16'"), "{yaml}");- assert!(yaml.contains("DAYTONA_SNAPSHOT_DISK: '96'"), "{yaml}");+ let (cpu, memory, disk) = super::snapshot_quota();+ assert!(+ yaml.contains(&format!("DAYTONA_SNAPSHOT_CPU: '{cpu}'")),+ "{yaml}"+ );+ assert!(+ yaml.contains(&format!("DAYTONA_SNAPSHOT_MEMORY: '{memory}'")),+ "{yaml}"+ );+ assert!(+ yaml.contains(&format!("DAYTONA_SNAPSHOT_DISK: '{disk}'")),+ "{yaml}"+ );assert!(yaml.contains("--cpu ${DAYTONA_SNAPSHOT_CPU} --memory ${DAYTONA_SNAPSHOT_MEMORY} --disk ${DAYTONA_SNAPSHOT_DISK}"),"{yaml}"