Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Run the agent in a separate container, virtual machine, or hosted sandbox with a dedicated workspace—not directly against your everyday files. Put only the task’s necessary inputs in that workspace, restrict writes to the working or output directory, deny access to credentials and unrelated files, and control network access separately. A sandbox is an enforced execution boundary; asking an agent in a prompt not to read something is not a substitute.

The right setup depends on what you are protecting and how much control you need. A hosted sandbox is usually the simplest managed option; a self-hosted container or VM gives you more control but makes you responsible for its configuration. In every case, keep credentials outside the agent’s workspace and review what it changes before running the result on your main system.

What does it mean to run an AI agent in a sandbox?

A sandbox is an isolated environment where an agent can access a deliberately limited set of files and tools. The agent may still read, change, or execute anything allowed inside that boundary, so the protection comes from enforcing the boundary—not from the agent’s promise to behave.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

OpenAI describes a sandbox as an isolated, Unix-like execution environment that can include a filesystem, shell, installed packages, mounted data, exposed ports, snapshots, and controlled access to external systems. The useful distinction is between the agent and the environment that runs its commands: the agent can be given a workspace without being given your entire computer. See OpenAI’s Sandbox Agents guide.

#1 Best Overall
Sandisk 2TB Extreme Portable SSD, Up to 1050MB/s, USB-C, USB 3.2 Gen 2, IP65 Water and Dust Resistance, Updated Firmware, External Solid State Drive, SDSSDE61-2T00-G25
  • Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity drive(1) (Based on internal testing; performance may be lower depending on host device & other factors. 1MB=1,000,000 bytes.)
  • Up to 3-meter drop protection and IP65 water and dust resistance mean this tough drive can take a beating(3) (Previously rated for 2-meter drop protection and IP55 rating. Now qualified for the higher, stated specs.)
  • Use the handy carabiner loop to secure it to your belt loop or backpack for extra peace of mind.
  • Help keep private content private with the included password protection featuring 256‐bit AES hardware encryption.(3)
  • Easily manage files and automatically free up space with the SanDisk Memory Zone app.(5). Non-Operating Temperature -20°C to 85°C

There are two separate questions to answer:

  • What can it see or change? This is the filesystem boundary: which files are mounted, which are readable, and which directories are writable.
  • Where can it connect? This is network egress: whether it can contact the internet, source control, package registries, or other services.

Restricting one does not automatically restrict the other. A project-only mount does not prevent a network connection, and a network block does not prevent an agent from reading a secret that is already mounted into its workspace.

Start by writing down the task’s minimum inputs and outputs. For example, a code-review run might need a repository checkout and a report directory, while a documentation run might need selected source files and a generated-output folder. This inventory becomes the basis for mounts, permissions, network rules, and the final review.

Why isn’t a prompt or a separate Git worktree enough?

A prompt expresses an instruction; it does not technically prevent a command from accessing files or network services that the runtime allows. A separate worktree or clone can reduce accidental edits to the original checkout, but it does not by itself stop the agent from reading other host files, accessing credentials, or reaching the network.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Think of a worktree as an organizational boundary and a sandbox as an enforced access boundary. A worktree can be part of a safer workflow, but it should sit inside an environment that limits what the agent can see and do. If a hosted tool provides a specific sandbox, check what it actually isolates rather than assuming the word “sandbox” means host files, network, and credentials are all protected.

A worktree is still useful for review. It gives you a clean diff and makes it easier to discard changes, but the checkout should be created inside the sandbox or mounted as the one deliberately permitted project path. Do not mount your home directory just to make a worktree convenient.

Which kind of sandbox should I choose?

Choose based on how much control you need over placement and configuration, and how much isolation the workload warrants. No option is universally safest: the strength of the boundary depends on its implementation, mounts, permissions, and network policy.

Option Useful when Trade-off
Hosted sandbox You want a managed workflow and a quicker setup. You have less control over runtime placement and provider policy.
Self-hosted container You want the data and automation to remain in your infrastructure. You are responsible for isolation, patching, mounts, and network policy.
Virtual machine or microVM The workload is untrusted, or you need a stronger boundary for nested tooling. Startup and resource costs are higher.
Separate worktree or clone You want to isolate repository edits as one layer of a broader setup. It does not by itself restrict access to other host files, credentials, or the network.

For managed and self-hosted environments, OpenAI documents separate environment choices in its Agents API architecture guide. Cloudflare’s coding-agent documentation describes a Linux container for each task and a Worker that controls which hostnames the sandbox can reach: Cloudflare Sandboxes. These are examples of approaches, not a guarantee that every hosted or container-based setup has the same controls.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sandisk 1TB Portable SSD, Up to 800MB/s Read Speeds, Black (Old Model) | External Solid State Drive, Compatible with Laptops & Tablets, Up to 2M Drop Protection, USB 3.2 Gen 2, USB-C to USB-A Cable
  • Solid state performance with up to 800MB/s read speeds in a portable drive. (Based on internal testing; performance may be lower depending on host device, interface, usage conditions and other factors. 1MB=1,000,000 bytes.)
  • Back up your content and memories on a storage solution that fits seamlessly into your mobile lifestyle.
  • Take it with you on your adventures—up to two-meter drop protection means this durable drive can take a beating. (Based on internal testing.)
  • Secure it to your belt loop or backpack for extra peace of mind thanks to the tough rubber hook.
  • From Sandisk, a brand professional photographers trust to take on assignments.

Compare options against the controls that matter to your task:

  • Filesystem visibility: Can the agent see only the task files, or does it inherit a broader home directory or host mount?
  • Write scope: Can it write only to a working directory, or to mounted files beyond the project?
  • Network egress: Is outbound access disabled, broadly enabled, or restricted to approved hosts?
  • Credential exposure: Are keys kept outside the workspace, or can code and shell commands read them?
  • Isolation strength: Is the workload in a managed environment, a container, or a VM/microVM, and what does that environment actually isolate?
  • Startup and persistence: What setup and resource overhead is acceptable, and what files or state survive the run?
  • Review workflow: Can you inspect output and changes before they are used on your host?

Cost is a design trade-off even when no product price is involved. Hosted environments reduce your setup and maintenance work. Self-hosted containers can be easy to automate but require you to supply patching, image maintenance, mounts, and network controls. VMs and microVMs generally have greater startup and resource overhead, which matters for short-lived or highly parallel tasks. Evaluate that overhead against the sensitivity and trust level of the workload rather than choosing only on launch speed.

How do I set up a safer agent workspace?

Build the environment around one task: define its boundary, add only the needed inputs, and grant only the access that task requires. The following sequence applies whether you use a hosted service or manage the sandbox yourself; exact controls and labels depend on the environment.

  1. Choose where it runs. Use a hosted sandbox when managed isolation suits the workflow. Choose a self-hosted container or VM when private data, custom software, or control over infrastructure requires it. Confirm which boundary the provider or runtime actually supplies.
  2. Create a fresh workspace. Prepare a manifest or image containing only the repository, input documents, helper scripts, and output directory needed for this run. OpenAI’s sandbox documentation says manifest paths are workspace-relative and cannot be absolute or escape the workspace using ... Keep unrelated repositories and personal files out of the workspace.
  3. Set filesystem permissions explicitly. Deny access to credentials, home directories, unrelated projects, and system data; make only the required project area writable. Codex permission profiles support read, write, and deny, with more-specific entries overriding broader ones. Check the effective permissions rather than assuming a broad rule protects a more-specific path. Details are in Codex Permissions.
  4. Set network access independently. Start with outbound network access disabled if the task does not need it. If it does, allow only the required services—for example, a package registry or source-control service—through an allowlist or proxy. OpenAI recommends limiting outbound traffic to approved endpoints; Cloudflare’s design gives the Worker responsibility for deciding which hostnames the sandbox can reach. See OpenAI Sandbox security and the Cloudflare Sandboxes documentation.
  5. Keep application credentials out of the workspace. Do not put a broad API key where the agent’s shell or code can read it. For self-hosted OpenAI environments, the documented approach uses a restricted environment key for executor registration while keeping the application key outside the sandbox. Consult OpenAI’s self-hosted sandboxes guide for that arrangement.
  6. Keep the control plane separate where possible. The orchestrator or harness should manage authentication, billing, audit logs, and approval state outside the environment that executes untrusted commands. OpenAI describes this as a harness around the model and a sandbox execution plane for commands and files. Its Agents API architecture guide explains the separation.
  7. Decide when the agent must ask. Set approval rules for requests that would broaden filesystem or network access. Approval policy determines when the agent pauses for a decision; sandbox enforcement determines what it can technically access. Use both rather than treating an approval prompt as a substitute for a restricted boundary. See ChatGPT Sandboxing.
  8. Inspect the output before using it on the host. Review the diff and hidden files before transferring changes or running project commands outside the sandbox. Pay particular attention to .git/hooks, CI workflows, build scripts, package-manager scripts, and agent configuration: these can execute code during later development actions. Docker discusses this risk in Docker Engine isolation.

What should the workspace manifest contain?

Keep the manifest task-specific and reproducible. Include the exact repository or source files the agent needs, any helper scripts that you have reviewed, and a clearly named output directory. Do not use a broad host path as a shortcut. OpenAI’s documented path rules require workspace-relative paths and reject absolute paths or paths that escape with ..; following that pattern prevents an input definition from silently reaching elsewhere on the host.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Decide whether the repository should be read-only or writable. A review or analysis task may need only read access plus a report directory. An editing task needs write access to the project area, but it does not automatically need write access to credentials, caches, unrelated repositories, or system directories. More-specific permission entries should be checked because they can override a broad rule.

Make the output boundary obvious. A dedicated directory for patches, reports, or generated files lets you copy back only approved artifacts. If the sandbox supports snapshots or persistence, document which state survives and which is discarded when the task ends.

How do I keep an agent from reading my .env files?

Keep secret files outside the sandbox workspace and deny access to them in the filesystem policy; do not rely on the agent to ignore a file it can read. A project’s .env file is only one possible source of credentials, so also avoid mounting your home directory, unrelated repositories, or other locations where keys may be stored.

Rank #3
SSK Portable SSD 500GB External Solid State Hard Drive USB C Up to 1050MB/s | USB3.2 Gen2 A&C Cable, SMART TRIM, LED Light, OTG, iPhone 18/17/16/15 Pro Compatible 4KHDR ProRes, Aluminum
  • Capacity Display Variance: 500GB external ssd often appears as around 465GB on Windows. MacOS can show full 500 GB capacity. This is binary calculation difference and doesn’t affect SSD hard drive actual physical storage
  • 1050 MB/s Speed: Instantly access to your files with blazing-fast 10Gbps external SSD read up to 1050MB/s and write up to 1000MB/s. LED Light indicates USB SSD instant activity
  • Data Security: Solid state drives S.M.A.R.T. health diagnostics​ and adaptive TRIM optimizing data block management ensures consistent write speeds and extends the longevity of the portable SSD
  • USB-C & USB-A Cable: Both cables featuring rapid USB 3.2 Gen2, this USB SSD effortlessly bridges devices, enabling seamless cross-platform file transfers and backup between computers, smartphones, tablets and iPhone
  • Always Fast: No slowdowns for large file transfers. With SLC caching (25% of current available capacity allocated as high-speed cache), this external SSD delivers steady 10Gbps for transfers within the cache capacity

Before a run, check what is actually present in the workspace and what paths its permissions allow. If a task needs a particular secret to contact a service, do not expose a general-purpose application key: use a narrowly scoped credential or a trusted control-plane mechanism when the environment supports one. The self-hosted OpenAI guidance specifically distinguishes a restricted environment key used for executor registration from the application key, which remains outside the sandbox: Self-hosted sandboxes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Also consider network access as a separate risk. A secret can be protected from direct file reads but still be exposed if it is injected into a process the agent controls or made available through an overly broad service. Limit network destinations and provide only the credentials the task genuinely requires.

Do not assume that hiding a filename is sufficient. Check environment variables, mounted credential directories, shell startup files, source-control configuration, and build tooling for alternate paths to the same keys. The safest default is that no secret is present; add a narrowly scoped credential only when the task cannot work without it, and keep the mechanism outside the ordinary workspace files.

What should I know before giving an agent Docker?

Do not mount the host Docker socket, commonly located at /var/run/docker.sock, into an agent container. Docker warns that doing so can give the agent full access to your environment, defeating the isolation you intended.

If the agent needs to build or run containers, use an approach designed to keep the Docker Engine separate from the host boundary. Docker describes its sandbox model as running a separate Docker Engine inside the sandbox VM. The exact setup depends on the product and runtime; do not assume that a nested container or an ordinary container automatically provides this separation. See Docker Engine isolation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Containerizing the agent does not remove the need to review mounts and privileges. A container with broad host mounts, powerful device access, or unrestricted network connectivity can undermine the intended boundary. Treat every mount and capability as part of the threat model, and keep the engine, credentials, and approval controls in the trusted control plane when the platform permits.

How should I review an agent’s changes before using them?

Review both the visible code changes and files that can affect what runs later. An agent can produce an ordinary-looking source-code diff while also changing hooks, automation, or configuration that executes during a future command or development action.

Rank #4
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400) | Everyday HDD storage. Plug-and-play backup. Windows & macOS. Adobe CC trial included. 1-Year Warranty
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
  • Inspect the complete diff, including hidden files and new files not yet tracked by Git.
  • Check .git/hooks, CI workflows, build scripts, package-manager scripts, and agent configuration for unexpected commands or altered behavior.
  • Keep output in a designated directory so it is clear what the agent produced and what you are choosing to bring back into your working environment.
  • Do not run a generated script or install dependencies on the host merely because the agent says the task is complete; inspect the files and commands first.

Docker specifically warns that hooks, workflows, build scripts, package-manager scripts, and agent configuration may execute code during later development actions. Review is therefore part of the boundary: sandboxing limits exposure during the run, while inspection helps prevent unsafe output from being trusted afterward.

A practical handoff is staged: first collect the diff and output, then inspect executable files and configuration, then run tests in the sandbox, and only afterward copy approved files to the host or open a pull request. Keep the original host checkout untouched until this review is complete.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do approvals and technical enforcement work together?

Approval prompts and sandbox rules solve different problems. An approval policy decides when the agent should pause and ask for permission, such as when it requests a broader directory or a new network destination. The sandbox determines whether a command can technically reach that directory or destination at all.

Use a narrow default boundary even if every expansion requires approval. A mistaken approval, an overly broad rule, or an unattended run should not turn into access to your home directory or unrestricted network. Conversely, a strict sandbox can prevent legitimate work if the required package registry or source-control service is not allowlisted. Define the expected access before the run and make exceptional requests visible.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What does a good sandbox setup look like for a coding task?

For a routine code change, create a clean workspace containing the relevant repository and task-specific inputs, not your whole home directory. Let the agent read the repository and write only where editing is necessary; deny unrelated paths, keep credentials outside the workspace, and begin with network access off.

If dependency installation or source-control access is essential, allow only the needed destinations through the environment’s network controls. Keep approval requirements for requests that expand access, and inspect the resulting diff and executable configuration before applying or running it on your host. This arrangement does not guarantee that code is harmless; it narrows what the agent can reach while making its output reviewable.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For an unfamiliar repository, start with a disposable workspace and treat setup files as executable. Do not transfer its hooks, workflows, build scripts, or package-manager changes to a trusted checkout without inspection. If the task does not need persistence, discard the workspace after collecting the approved output.

Best Value
Sale
Samsung T7 Portable SSD 1TB Titan Gray, USB 3.2 Gen 2, Up to 1,050MB/s | Reliable External Solid State Drive Storage for Gaming, Students, Professionals (MU-PC1T0T/AM)
  • MADE FOR THE MAKERS: Create; Explore; Store; The T7 Portable SSD delivers fast speeds and durable features to back up any endeavor; Build your video editing empire, file your photographs or back up your blogs all in an instant
  • SHARE IDEAS IN A FLASH: Don’t waste a second waiting and spend more time doing; The T7 is embedded with PCIe NVMe technology that brings fast read and write speeds up to 1,050/1,000 MB/s¹, making it almost twice as fast as the T5
  • ALWAYS MAKE THE SAVE: Compact design with massive capacity; With capacities up to 4TB, save exactly what you need to your drive – from large working files to game data and everything in between
  • ADAPTS TO EVERY NEED: Whether using a PC or mobile phone, count on the T7 for extensive compatibility²; It’s a true team player when it comes to heavy-duty application usage or file-saving
  • HI RESOLUTION VIDEO RECORDING: Record Ultra High Resolution (4K 60fs) videos directly onto the T7 Portable SSD with your favorite camera or mobile devices; Supports iPhone 15 Pro Res 4K at 60fps video and more³

There is no single isolation setting that makes every workload safe. The important design choice is to decide what the task needs, expose only that material, enforce file and network restrictions separately, and keep the ability to grant broader access under your control.

A quick pre-run and post-run checklist

  • Identify the exact input files, writable directory, and expected outputs.
  • Confirm that no .env files, home directories, unrelated repositories, or broad credential stores are mounted.
  • Verify effective read, write, and deny rules, including more-specific overrides.
  • Start with network access disabled; if required, allowlist only named services or hostnames.
  • Keep application keys and approval, billing, and audit state in the control plane.
  • Confirm that no host Docker socket is available to the agent.
  • After completion, inspect hidden files, hooks, workflows, scripts, and configuration as well as the ordinary diff.
  • Copy back only approved outputs, and keep the sandbox or snapshot available until review is finished if persistence is useful.

Frequently Asked Questions

Will an agent sandbox keep my files after the session ends?

That depends on the sandbox provider and how its workspace is configured. Check whether the environment preserves its workspace, snapshots, or outputs, and copy out only the files you intend to retain.

Can I let a sandboxed agent install packages?

Only if the task needs it and the sandbox can reach the relevant package service. Allowing package installation may require network access, so restrict destinations rather than enabling unrestricted outbound connections.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is a sandbox safe for a repository I don’t trust?

Treat unfamiliar code and its setup scripts as potentially executable, and use a boundary that limits both host access and network egress. Do not run its generated scripts outside that boundary until you have inspected them.

Do approval prompts replace sandbox permissions?

No. An approval prompt is a policy decision about when work pauses; the sandbox’s technical rules determine what commands can access. A robust setup uses both.

Should network access be enabled for every coding task?

No. Begin with outbound access disabled. If dependencies or source control are required, allow only the specific package registries, repositories, model endpoints, or other services the task needs.

Is a separate Git clone enough to protect my computer?

No. A clone or worktree limits accidental edits to that checkout but does not prevent an agent from reading other mounted files, finding credentials, or making network connections. Put the clone inside a real sandbox.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What should I check before copying an agent’s patch to my host?

Review the full diff, hidden and untracked files, .git/hooks, CI workflows, build and package-manager scripts, and agent configuration. These files can execute code during later development actions.

Can a container use my host Docker installation?

Do not mount the host Docker socket into the agent container. Docker warns that this can provide full host access. If container builds are required, use a design with a separate Docker Engine inside the sandbox boundary.

The Bottom Line

Give an agent a purpose-built workspace, not your computer: mount only required inputs, write only to an approved directory, keep secrets in a trusted control plane, disable network access by default, never expose the host Docker socket, and review every executable change before bringing it back to the host.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.