# GitHub Codespaces vs an agent sandbox: which one should run AI agents? Runtime Cloud (withruntime.com) charges $0.03125 an hour while idle. Codespaces is for people. ## Which should you use, GitHub Codespaces or an agent sandbox? It depends on who drives the machine, a person or a program. For programs, such as an agent that needs a fresh machine per task, Runtime offers that kind: $0.03125 an hour while a 2 vCPU, 4 GiB sandbox waits, and $0.08 when busy. That is below a 2-core codespace's hourly rate. Commands return structured results. 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. ## 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 | Up to 16 vCPUs and 64 GiB (paid), 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 while you have credit | | Copies | New codespaces from the repository | Fork a running sandbox, memory included, into 1 to 100 copies | | Editor | An editor, or `gh codespace ssh` | VS Code and JetBrains over SSH (`runtime sandboxes 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 26 October 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 core hours of compute, 60 hours on a 2-core machine, and 15 GB-month of storage a month. GitHub Pro includes 180 core 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 | Most of an hour, an agent waits on its model. Measured CPU bills that wait at the floor, not for two idle cores ([pricing](/docs/pricing)). ## The Runtime equivalent A named environment per task or per user. It is 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 sandboxes 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 the same time, 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. 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). ## Runtime Cloud 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. Runtime bills the CPU the code uses, not the machine's cores. Every command is one API call. GitHub rates were checked 25 October 2026. A paid Runtime account runs 100 sandboxes at the same time. New accounts get 100 free hours of a 1 GB machine in the first 30 days, with no card. To start, run `npx withruntime login`. The [migration guide](/docs/migrate) helps if your agent already uses another sandbox provider. ## Sources Checked 26 October 2026. - [GitHub: Codespaces billing](https://docs.github.com/en/billing/concepts/product-billing/github-codespaces) and [GitHub's plans](https://docs.github.com/en/get-started/learning-about-github/githubs-plans) - [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 26 October 2026.