Sandbox
What it is
Section titled “What it is”The Sandbox is Foundry’s flagship execution surface. It provisions ephemeral AI coding environments — Docker containers orchestrated via Cloudflare Workers and Durable Objects — scoped to individual tasks. Each sandbox runs Claude Code with full repository access, real-time log streaming, an interactive terminal, file diff viewer, code editor, and multi-turn chat.
Why it matters
Section titled “Why it matters”Sandboxes turn AI plans into working code. Instead of copy-pasting AI output into a codebase, sandboxes give agents isolated environments where they can clone repos, install dependencies, write code, run tests, and auto-commit changes — all observable in real time through the HUD.
Key concepts
Section titled “Key concepts”- HUD (Heads-Up Display): Bottom bar with six tabs — Logs, Terminal, File Changes, Editor, Audit, Chat — accessible via
SandboxHUD - HUD context: State management via
SandboxHUDContext(useReducer with OPEN_TAB, CLOSE_TAB, FOCUS_TAB, SET_SUB_TAB, TOGGLE_EXPANDED, OPEN_CONFIG actions) - Toggle shortcut:
Cmd+J(Mac) /Ctrl+J(Windows) to expand/collapse the HUD - Log stream:
SandboxLogStreamshows real-time container output as the sandbox progresses through stages - Terminal:
SandboxTerminalprovides an interactive xterm.js terminal with WebSocket connection (HMAC token auth) - File changes:
SandboxFileChangesdisplays git diffs produced by the AI agent - Editor:
SandboxEditorfor viewing and editing files within the sandbox - Chat panel:
ChatPanelenables multi-turn conversation with the AI agent during execution - Config panel:
SandboxConfigPanelconfigures sandbox parameters (AI provider, model, environment variables) - Stage progress:
StageProgresstracks the 10-stage setup pipeline: containerProvision, systemSetup, authSetup, claudeConfig, gitClone, depsInstall, mcpInstall, workspaceCustomization, healthCheck, ready - Status badge:
SandboxStatusBadgeshows the current sandbox lifecycle state - Runtime mode badge:
RuntimeModeBadgeindicates whether the sandbox is running locally or in production - Manager page:
SandboxManagerPageprovides fleet management across all active sandboxes - Settings page:
SandboxSettingsPageconfigures default sandbox behavior and environment vault - Surface components:
SandboxSurfaceComponentsprovides reusable sandbox UI primitives
How to use it
Section titled “How to use it”- Open a task detail page and click Launch Sandbox.
- The sandbox provisions through 10 stages — watch progress in the HUD log tab.
- Once the sandbox reaches
ready, the AI agent begins executing the assigned skill. - Monitor real-time output in the Logs tab.
- Switch to the Terminal tab to interact directly with the container.
- View AI-generated code changes in the File Changes tab.
- Use the Chat tab to give the agent additional instructions mid-execution.
- Changes auto-commit and push via PostToolUse hooks (5-second debounce).
- Close the sandbox when work is complete — the container is cleaned up automatically.
Data model
Section titled “Data model”This feature uses the following tables:
sandboxSessions— Session lifecycle, linked task, container statesandboxConfigs— Per-program sandbox configurationsandboxEnvVault— Encrypted environment variables for sandbox injectionsandboxAiProviderConfigs— AI provider and model settingssandboxPresets— Reusable sandbox configuration presetssandboxQueue— Queue-based fallback when the sandbox worker is unavailablesandboxLogs— Persisted log entries from sandbox executionsandboxChat— Multi-turn chat messages within a sessionsandboxSubtasks— Subtask tracking within a sandbox sessionsandboxAudit— Audit records for sandbox actionssandboxNotifications— Notifications from sandbox events