---
title: "AI agent sandbox boundaries: what a Cohub Space isolates"
description: "Cohub's AI agent sandbox isolates per Space, not per command. Measured 2 CPU and 4 GiB limits, what persists vs resets, read-only paths, and pre-run checks."
lang: "en"
canonical: "https://cohub.live/guides/ai-agent-sandbox"
image: "https://cohub.live/_seo/covers/ai-agent-sandbox/og.webp"
updated: "2026-12-02"
---

# What an AI agent sandbox isolates in a Cohub Space, and what stays reachable

In Cohub the agent's sandbox is the Space's own Linux environment: one runtime per Space, the project on a persistent volume, a fixed CPU and memory quota. A fresh container per command would start clean each time; this one keeps state, so what matters is what it keeps and what it shares.

- **Who:** A developer about to let an agent run commands on a project, who needs to know what those commands can reach and what they leave behind.
- **When:** You are choosing between an agent on your laptop, a cloud Space and a per-command sandbox, and want the isolation each one actually gives.
- **Why:** A Space's sandbox is one long-lived runtime next to the project files, so its limits differ from a container that starts fresh for every command.

![A shallow pale-grey enamel tray with a single vermilion-red rim sits on a charcoal workbench, holding a stack of off-white paper and one short steel ruler; the bench outside the tray is empty.](https://cohub.live/_seo/covers/ai-agent-sandbox/hero.webp)

![Your cohub run command and the agent's bash command reach the same /workspace in one Space. A restart keeps files under /workspace and Saves, while processes, /tmp and packages outside /workspace are gone; the standard runtime measured 2 CPUs and 4 GiB.](https://cohub.live/_seo/covers/ai-agent-sandbox/flow-en.svg)

One Space, one runtime: what both commands touch, and what a restart keeps.

An AI agent sandbox in Cohub isolates at the Space level, not per shell command. Every turn from an agent and every `cohub run` call from your CLI executes inside the same Linux runtime, so checking what persists, what resets on restart, what stays read-only, and what stays open matters before you hand over a repository.

## The boundary is the Space, not the command
One Space gets one Linux environment running as `uid=1000(node)`. In a test run, a CLI call wrote `persist-check.txt` under `/workspace` at 04:24 and a Chat turn four minutes later read the same file back—no sync step, because both ran in the same runtime.

Measured through the CLI on 2026-11-26 (`cohub` CLI 10.37.1, sandbox v2.111.0) on a fresh `standard` Space with the `default` image:

```bash
cohub spaces create --name "Sandbox check"
cohub -s <space-id> run --command '
  uname -srm
  cat /sys/fs/cgroup/cpu.max
  cat /sys/fs/cgroup/memory.max
  nproc'
```

```text
Linux 6.6.102-8.alnx4.x86_64 x86_64
200000 100000
4294967296
8
```

`200000 100000` sets the cgroup quota to 2 CPUs and `4294967296` caps memory at 4 GiB. `nproc` reports `8` from the host, so size builds against the cgroup values rather than `nproc`.

![A Cohub Chat in dark theme: the agent ran three bash checks in the Space's sandbox and listed the kernel, cpu.max 200000 100000 (2 CPUs), memory.max 4 GiB, Node v26.12.1, Python 3.13.5, Chrome 155 and the persist-check.txt file left in /workspace](https://cohub.live/_seo/img/ui/ui-sandbox-check-desktop-dark.webp)

A test Space on cohub.live, 2026-11-26

Commands inside the same Space share one user, one kernel, and accumulated state: a failed package install stays broken until you remove it, reinstall it, or restore a Save. For full lifecycle, virtual screen, and port-preview details, read the [Files & Sandbox specification](https://cohub.live/docs/workspace/files-and-sandbox).

## What persists and what resets
A new Space created from the CLI starts with `autoDestroy: idle` and a 3600-second (one-hour) idle TTL. When the sandbox stops or restarts, state splits cleanly in two:

- **Persists across restarts**: `/workspace` (mounted on a separate network volume) and any Saves you create. Keep project source and project-local dependencies under `/workspace`.
- **Resets on stop or restart**: running processes (dev servers, published port listeners, `nohup` jobs), `/tmp`, and packages installed outside `/workspace` such as global `npm` binaries.

Run `cohub spaces config <space-id> --auto-destroy never` to keep the sandbox running or `--idle-ttl` to change the window. Place repeatable tool installs in `.cohub/setup.sh`, which runs on every new sandbox.

The image itself is fixed to two platform options: `default` (measured with Node 26.12.1, Python 3.13.5, git, `ffmpeg`, `xvfb-run`, ripgrep, Chrome for Testing 155, NumPy, and build tools) and `game` (adds Godot and Blender). A project can request a different spec (`standard`, `boost`, `ultra`) or the `game` image in `.cohub/sandbox.json`—for example, `{"version": 1, "spec": "boost"}` sets `pendingRestart: true` in `cohub spaces config <space-id> --json` until the sandbox restarts, and falls back to a lower spec with a warning if your plan does not cover the request. `.cohub/sandbox.json` does not accept custom image URLs, extra mounts, environment variables, or privileged mode.

## Read-only paths
`/configs` and `/mods` are mounted read-only inside the runtime; running `touch /configs/x` returns `Permission denied`.

Because `/mods` is read-only, mounting another Space as a Mod lets the agent inspect its latest Save without allowing commands in the current Space to modify the source Space.

## What the network and secrets can reach
Outbound network egress is open by default: `curl -s -o /dev/null -w '%{http_code}' https://example.com` returned `200` in the 2026-11-26 check. A command that can fetch dependencies can also transmit files outward.

Because every command runs as `uid=1000(node)`, an agent turn can read every file under `/workspace`—including uploads added by other Space members—as well as environment variables configured on the Space. Keep sensitive credentials out of Spaces shared with untrusted collaborators or scripts.

Local Runtime (`cohub runtime up`) has a different reach than a cloud Space: file paths are fenced to the project folder, while shell commands run as your local OS user and can reach the rest of your computer. Run commands you do not want touching your laptop inside a cloud Space instead.

If you need to control cluster-level isolation, networking, and storage on your own infrastructure, see [self-hosting Cohub on your own cluster](https://cohub.live/guides/self-host-cohub).

## Checks before running code you did not write
Before letting an agent execute third-party repositories or unfamiliar build scripts in a Space:

1. **Audit credentials and uploads**: verify the Space has no personal tokens, production keys, or sensitive files in `/workspace` or Space environment variables, since outbound network access is open.
2. **Create a Save first**: snapshot `/workspace` before installs or migrations so you can restore or fork from a known-good tree (see [Cohub Saves documentation](https://cohub.live/docs/workspace/saves)).
3. **Confirm the execution target**: make sure the chat targets a cloud Space rather than a Local Runtime connected to your own laptop.
4. **Check whether per-Space state fits**: if your own product needs a fresh ephemeral container per untrusted request, a Cohub Space pairs one shared runtime with Chats, files, and Apps rather than spinning up a container per command.

## Reference in the docs

**This page:** Whether a Space's sandbox is the right place to run an agent's commands, or the task needs a fresh container per run or your own machine.

- [Files & Sandbox](https://cohub.live/docs/workspace/files-and-sandbox): what the Sandbox is, ports and previews, and what happens on idle or restart
- [Saves](https://cohub.live/docs/workspace/saves): freezing the workspace at a known-good state before a risky run
- [CLI](https://cohub.live/docs/developers/cli): the cohub commands used here: spaces create, run, config

## FAQ

### Is a Cohub sandbox a container per command?

No. A Space has one runtime, and the agent's commands and your CLI commands run in it on the same workspace. A restart replaces the runtime; the files stay.

### Can I bring my own Docker image or install system packages?

No. The .cohub/sandbox.json file accepts only image (default or game) and spec (standard, boost, ultra). Keep project dependencies under /workspace, which persists, and put repeatable setup in .cohub/setup.sh.

### What happens to my files when the sandbox stops?

/workspace stays, because it is a separate volume from the container. Processes and /tmp end with the sandbox. Saves freeze the workspace on purpose, so you can start a new Space from one.

## Related

- [How to run Claude Code in the cloud inside a Cohub Space](https://cohub.live/guides/run-claude-code-in-cloud): To run Claude Code in the cloud on Cohub, install it in a Space's sandbox with a startup script. The walkthrough checks CLI authentication with placeholder keys, then shows how to publish a server and recover project files with Saves.
- [How to publish a running app from an AI sandbox as a live link](https://cohub.live/use-cases/publish-app-from-ai-sandbox): To publish a running app from an AI sandbox in Cohub, run one CLI command, or use the Publish dialog, to point an App at the port your dev server listens on; static output can go out as a folder or a single HTML file instead.
- [How one Cohub Space works as an AI agent workspace for indie developers](https://cohub.live/use-cases/indie-developer-ai-workspace): Cohub is an AI agent workspace for indie developers: each Space has a cloud sandbox the agent runs commands in, port previews, one-command publishing and prompts that run on a schedule.

## Sources

- [Cohub docs: Files & Sandbox](https://cohub.live/docs/workspace/files-and-sandbox)
- [Cohub docs: Saves](https://cohub.live/docs/workspace/saves)
- [Cohub docs: CLI](https://cohub.live/docs/developers/cli)

Updated Dec 2, 2026
