# GitHub Codespaces vs an agent sandbox: which one should run AI agents? Codespaces gives a person a cloud dev environment per repository; an agent sandbox gives code a machine it creates and drives by API. **Runtime charges $0.03125 to $0.08 an hour for 2 vCPUs and 4 GiB, against $0.18 an hour for a 2-core codespace**, because it bills the CPU the code uses rather than the machine's cores. A new sandbox ran its first Python command 351 ms after the create request at the median, measured on 24 September 2026 ([speed](/docs/speed)), and every command is one API call. GitHub rates checked 25 September 2026. ## What Codespaces is built for GitHub describes a codespace as a development environment for a repository. When you create one, "a virtual machine (VM) is created", "dedicated and private to you", and "GitHub Codespaces uses a Docker container as the development environment". You connect to it with an editor, or from a terminal with `gh codespace ssh`. - **Files.** `/workspaces` is "a persistent directory that is mounted into the container". Changes elsewhere survive a stop and start but "are not preserved when you rebuild the container". - **Idle timeout.** "By default this period is 30 minutes", and it can be set from 5 to 240 minutes. - **Retention.** Stopped codespaces are deleted after 30 days inactive by default, and 30 days is the maximum. - **API.** The REST API creates a codespace in a repository and starts and stops it (`POST /repos/{owner}/{repo}/codespaces`, `POST /user/codespaces/{codespace_name}/start`). Commands inside run over a connection such as `gh codespace ssh`. ## Side by side | | GitHub Codespaces | Runtime sandbox | | ------------- | -------------------------------------------- | ----------------------------------------------------------------------- | | Made for | A developer working on one repository | Code that an agent or a program starts, runs and throws away | | Machine | A dedicated VM with the dev container inside | A Firecracker microVM with its own Linux kernel | | Run a command | Connect, then run it | `sbx.exec(...)`, with exit code, output and a timeout in the result | | Sizes | 2 to 32 cores | vCPUs, memory and disk set per sandbox; 2 vCPU and 4 GiB by default | | Idle | Stops after 5 to 240 minutes; files kept | Pauses with files, memory and running processes, kept 1 to 365 days | | Copies | New codespaces from the repository | Fork a running sandbox, memory included, into 1 to 10 copies | | Editor | An editor, or `gh codespace ssh` | VS Code and JetBrains over SSH (`runtime sandbox ssh config --install`) | | Billing | By machine type while running, plus storage | Measured CPU plus reserved memory while running; paused storage | ## What each costs GitHub's rates, checked 25 September 2026: compute from $0.18 an hour on a 2-core machine to $2.88 on 32 cores, "proportional to the number of processor cores", and storage at $0.07 per GB-month. A personal account on GitHub Free includes 120 hours of compute and 15 GB-month of storage a month; GitHub Pro includes 180 hours and 20 GB-month. Runtime at 2 vCPU and 4 GiB: $0.03125 an hour waiting (memory plus a CPU floor of a twentieth of a vCPU) and $0.08 an hour with both CPUs busy. | Usage, past any free allowance | Codespaces, 2-core | Runtime, 2 vCPU and 4 GiB | | ---------------------------------- | -------------------- | ---------------------------------------------- | | One hour | $0.18 | $0.03125 waiting, $0.08 busy | | A working month, 8 hours × 21 days | 168 × $0.18 = $30.24 | 168 × $0.03125 = $5.25 to 168 × $0.08 = $13.44 | | Stored while idle | $0.07 per GB-month | $0.08 per decimal GB-month, memory included | An agent spends most of an hour waiting on its model, which is where measured CPU pays: the sandbox is charged for the floor, not for two idle cores ([pricing](/docs/pricing)). ## The Runtime equivalent A named environment per task or per user: found again if it exists, paused after 15 quiet minutes, and woken by the next command. ```ts check import { Sandbox } from "withruntime"; const dev = await Sandbox.getOrCreate("issue-4821", { idlePauseSeconds: 900 }); await dev.exec("git clone https://github.com/octocat/Hello-World.git repo || true", { timeoutMs: 120_000, }); const run = await dev.exec("cd repo && git log --oneline -1"); console.log(run.stdout); ``` ```python check from withruntime import Sandbox dev = Sandbox.get_or_create("issue-4821", idle_pause_seconds=900) dev.exec("git clone https://github.com/octocat/Hello-World.git repo || true", timeout_ms=120_000) print(dev.exec("cd repo && git log --oneline -1").stdout) ``` To look over the agent's shoulder in your own editor: ```bash no-run runtime sandbox ssh config --install # then connect VS Code to issue-4821.runtime ``` ## Which one fits - **Pick Codespaces** for people: a developer, a class or a reviewer who wants a ready editor for a repository, inside GitHub's billing and its free monthly hours. - **Pick an agent sandbox** for programs: an agent that needs a fresh machine per task, a hundred at once, commands with structured results, network rules it cannot change, keys it never holds, and a bill that stays small while it waits on the model. A paid Runtime account runs 100 sandboxes at once to start, and new accounts get 50 free sandbox hours, no card. More: [coding agent sandbox](/use-cases/coding-agent-sandbox), [per-user dev environments](/use-cases/per-user-dev-environments), [pause and resume a sandbox](/how-to/pause-and-resume-a-sandbox), [SSH and editors](/docs/editors). ## Sources Checked 25 September 2026. - [GitHub: Codespaces billing](https://docs.github.com/en/billing/concepts/product-billing/github-codespaces) - [GitHub: Codespaces deep dive](https://docs.github.com/en/codespaces/about-codespaces/deep-dive) - [GitHub: timeout period](https://docs.github.com/en/codespaces/setting-your-user-preferences/setting-your-timeout-period-for-github-codespaces) and [automatic deletion](https://docs.github.com/en/codespaces/setting-your-user-preferences/configuring-automatic-deletion-of-your-codespaces) - [GitHub: Codespaces REST API](https://docs.github.com/en/rest/codespaces/codespaces), [gh codespace ssh](https://cli.github.com/manual/gh_codespace_ssh) - Runtime [pricing](/docs/pricing), [speed](/docs/speed) and [SSH and editors](/docs/editors) Facts on this page were checked on 25 September 2026.