Skip to content

How cloud coding agents prepare their environments: setup scripts, cached state and network rules

Codex, Claude Code on the web and GitHub's Copilot cloud agent all prepare a workspace before the agent starts. How each one does it, the pattern they share, and what to copy if you run your own agents.

Harshraj

7 min read

How do cloud coding agents set up their environment?#

Cloud coding agents prepare their environment in two phases. First a setup phase checks out the repository, installs dependencies and gets the toolchain ready, usually from a script you write, with the network open. Then the agent phase runs the agent itself, with the network restricted and secrets kept out of reach. The prepared state is cached so the next task skips the setup. OpenAI's Codex, Anthropic's Claude Code on the web and GitHub's Copilot cloud agent each work this way, with different defaults. If you run your own agents, the same split is worth copying.

Codex: a container, a script and a twelve-hour cache#

When a Codex cloud task starts, "Codex creates a container and checks out your repo at the selected branch or commit SHA." Your setup script runs next, with internet access, so it can install packages. The script runs "in a separate Bash session from the agent", which catches people out: variables it exports do not carry into the agent's shell.

The prepared container is reused, because "Codex caches container state for up to 12 hours to speed up new chats and follow-ups." When a cached container comes back, an optional maintenance script runs instead of the full setup, which is the place for a quick dependency refresh after a pull.

Then the agent phase begins, and the defaults tighten. "During the agent phase, internet access is off by default, but you can configure limited or unrestricted access." Secrets go away completely: they are "only available to setup scripts", and "for security reasons, secrets are removed before the agent phase starts." The default image is called universal, a broad toolchain published as openai/codex-universal so teams can reproduce it locally.

Claude Code on the web: four network levels and a snapshot of the filesystem#

Anthropic's cloud sessions run in what it calls cloud environments. Each one can carry a setup script, environment variables, network secrets and a network policy, and the same environments serve every place a cloud session can start, from the browser to the terminal.

The network policy has four levels:

LevelWhat a session can reach
Noneno outbound access through the session's network
Trustedan allowlist that covers package registries, GitHub and cloud SDKs
Fullany domain
Customyour own allowlist, with or without the defaults

The caching works differently from Codex. The setup script runs the first time a session starts in an environment, and when it finishes within roughly five minutes, "Anthropic snapshots the filesystem and reuses that snapshot as the starting point for later sessions." New sessions start with the dependencies, tools and Docker images already on disk. The docs are careful about the limit: the cache keeps what was written to disk and "loses anything that was only running", so a database the script started has to be started again in each session. The cache is rebuilt when the script or the allowed hosts change, and when it expires after about seven days.

Secrets get their own treatment too. An environment can hold network secrets "that sessions use without seeing them", attached to requests for named hosts, so the agent can call an API whose key it never reads.

Copilot cloud agent: GitHub Actions as the environment#

GitHub took the path its users already know. "Copilot has access to its own ephemeral development environment, powered by GitHub Actions", and you customise it by adding a workflow file, .github/workflows/copilot-setup-steps.yml, with a single job that "MUST be called copilot-setup-steps or it will not be picked up by Copilot." The steps run in Actions before Copilot starts, so anything a CI job can install, the agent's environment can have.

Bigger work gets bigger runners: the docs offer larger runners "for better performance (CPU and memory), more disk space." Teams that want the agent on their own machines can use self-hosted runners, with a firm recommendation attached: "only use Copilot cloud agent with ephemeral, single-use runners that are not reused for multiple jobs." The network side is a firewall that is strict by default and configurable per repository, with one catch: it "is not compatible with self-hosted runners", so a team that moves to its own runners also takes over the network rules.

The pattern they share#

Lay the three side by side and the same four decisions appear.

Setup is code. All three ask for a script or a workflow, checked into the repository or stored with the environment, instead of a person clicking through a machine. That makes the environment reviewable and repeatable, and it means a new hire's agent gets the same toolchain as everyone else's.

Prepared state is cached. Containers stay cached for up to twelve hours on Codex, and Claude Code keeps a filesystem snapshot for about a week. Copilot's setup is an Actions workflow, where the usual Actions caching is available. Nobody wants every task to start with a fresh dependency install, because an agent that waits four minutes for npm install before each task loses most of its time there.

The agent phase gets less network than the setup phase. Installing packages needs the internet; fixing a bug in checked-out code mostly does not. Every one of these products separates the two, and two of them close the network by default once the agent starts.

Secrets stay away from the model. Before the agent runs, Codex removes them. Claude Code lets sessions use them without seeing them. The shared assumption is that anything the agent can read, a prompt injection can make it print.

What to copy if you run your own agents#

Teams building their own coding agents, or running open source ones at scale, face the same problems without a vendor's defaults. Four habits carry over directly.

Write the setup as a script and keep it in the repository, then treat it like code: review it and pin what it installs. A setup that pulls the latest version of everything gives you a different environment every morning.

Build the prepared environment once and start every task from a copy of it. The difference shows up in time to feedback, the delay between the agent's change and the result of checking it, which we covered in Time to feedback. A copy that already has the dependencies installed and the build warm turns a multi-minute first step into a short one.

Give the setup step and the agent step different network rules. Open the network to the package registries while installing, then close it, or allow only the hosts the task needs, before the agent runs.

Keep long-lived processes out of the cache. As the Claude Code docs point out, a cached filesystem does not include the database the setup started. Start services per task, or as part of the task's own script, so the agent never assumes a service is running when it is not.

Promigence supports this way of working. A snapshot can be built from your repository with its dependencies installed, and a snapshot built with a verify command runs that command when it is built, so a broken environment fails at build time instead of in the middle of an agent's task. Every sandbox then starts from that checked snapshot, ready for its first command in 207 ms at p50 through the CLI, and is billed per second. The snapshot and fork guide walks through it.

FAQ#

What is a setup script for a coding agent?#

It is a script that prepares the agent's environment before the agent starts: installing dependencies, building the project and setting up tools. Each of these products runs one: Codex, Claude Code on the web and Copilot cloud agent. All of them let the setup reach the internet.

Do cloud coding agents have internet access?#

During setup, yes. During the agent's own work it depends on the product and your settings. In the agent phase, Codex turns internet access off by default, Claude Code offers four levels from none to full, and Copilot cloud agent uses a firewall that is strict by default.

How long do cloud coding agents cache their environments?#

Codex caches container state for up to 12 hours. Claude Code on the web reuses a filesystem snapshot of the setup result for about seven days, and rebuilds it sooner if the setup script or the allowed hosts change.

Why are secrets removed before a coding agent runs?#

Because anything the agent can read can be leaked if the agent is steered by a hostile instruction. Before the agent phase, Codex removes secrets, and Claude Code lets sessions use network secrets without being able to read them.

Sources#

SourceWhat it supportsRead
OpenAI Codex: cloud environmentsthe start sequence, setup and maintenance scripts, the 12-hour cache, internet off by default, secrets removed, the universal image25 Oct 2026
Claude Code: cloud environmentsthe four network levels, the filesystem snapshot cache and its limits, network secrets25 Oct 2026
GitHub Docs: customize the Copilot cloud agent environmentthe Actions-powered environment, the setup workflow, larger and self-hosted runners, the firewall25 Oct 2026
Promigence home page207 ms ready through the CLI25 Oct 2026

More in the Promigence blog, or follow it by RSS.

Request access

Leave your work email and we will email you an invite code. $10 free, no card. $40 more when you add one.

See our Privacy Policy for how we use your email.

Request access

Leave your work email and we will email you an invite code. $10 free, no card. $40 more when you add one.

See our Privacy Policy for how we use your email.