Codex in the cloud: delegating background tasks and receiving pull requests

November 3, 2026

Updated:

Guide
Codex in the cloud: delegating background tasks and receiving pull requests

What is Codex Cloud?

Codex Cloud is a way to delegate programming tasks to Codex running on a virtual machine managed by OpenAI instead of on your computer: you pick a GitHub repository, describe the task, Codex edits the code, runs tests, then returns a diff for you to review, commit, or open a pull request. According to the "Codex Cloud" and "Cloud environments" pages in the Codex documentation (developers.openai.com/codex redirects to learn.chatgpt.com/docs, read on 03/11/2026), tasks in the cloud continue running when your machine is asleep and can be reopened from the web, phone, or desktop app. This post does not promise that pull requests created by AI are correct or safe to merge immediately. OPCAIOS also hasn't used Codex Cloud to open pull requests yet, so the instructions are based on documentation only. General introduction is in the post What is Codex.

Diagram of Codex Cloud: select GitHub repository, Codex sets up environment (installation script, network, environment variables, network secret), publishes environment, each task runs in its own virtual machine, returns diff and test results, owner reviews then opens pull request
Environment is prepared once, each task runs separately, owner reviews before merging. Diagram: OPCAIOS.

How is Codex Cloud different from Codex CLI?

Codex Cloud differs from Codex CLI in where the command runs: Codex CLI runs on your machine in the operating system's sandbox, while Codex Cloud runs each task in its own virtual machine managed by OpenAI, built from a pre-prepared "environment". According to the "Cloud environments" page (read on 03/11/2026), the default virtual machine for the Plus plan has 2 vCPU, 8 GiB memory, 8 GiB disk; Pro, Business, Enterprise plans have 4 vCPU, 16 GiB memory, 32 GiB disk. The status of a task is kept for a maximum of seven days from the last time you resumed it. The Codex Cloud (Legacy) version still serves Code Review and GitHub, Linear integration, and plans to shut down. Current limitations according to the documentation: no browser and Computer Use on the cloud yet, no support for self-hosted GitLab and GitHub Enterprise Server, personal skills on the machine are not synced up, only skills in the repository can be used.

How do you connect GitHub to Codex Cloud?

Connecting GitHub to Codex Cloud happens when you create an environment. The steps according to the "Codex Cloud" page (read on 03/11/2026):

  1. Open ChatGPT on the web or desktop app, sign in to your ChatGPT account.
  2. Select Work in > Cloud, open Select environment, choose Create environment.
  3. Pick a GitHub repository, connect GitHub if asked, click Get started.
  4. Codex reads the repository, installs dependencies, runs a test process; you fill in any missing information.
  5. View the setup report, save, click Publish, then start a new task.

Only grant GitHub permission to the repositories you actually need.

What does Codex Cloud's runtime environment include?

Codex Cloud's runtime environment is a reusable set of configuration used for all tasks: code repository, dependencies, tools, and access settings. According to the "Cloud environments" page (read on 03/11/2026), Codex automatically detects the runtime, package version, and services from the repository, then records the tested settings in two fields: Install script (command to install dependencies) and Start skill (instructions to start the service, check readiness). When published, the system snapshots the prepared file system; each new task starts from that snapshot, old tasks keep their own files, including uncommitted changes. To update, Edit then Republish; running tasks are not affected. Pre-writing lint and test commands in AGENTS.md helps Codex know how to self-check; see What is AGENTS.md.

How are network and secret variables handled on Codex Cloud?

Network on Codex Cloud is configured per environment with three levels: allow all public internet, allow only package manager domain names (preset Package managers, including npm, PyPI and many other registries), or add individual domains. Secret values split into two types according to the "Cloud environments" page (read on 03/11/2026):

Type Used for How to pass
Environment variable Values the program must read directly Pass straight into the program
Network secret Key sent to a specific HTTPS service Program only sees placeholder value; proxy replaces it with real key when calling the permitted domain, port 443

The advantage of network secret: the real key is not in the process or files that the agent can read. There's also VPN via Tailscale and OIDC for cloud resources.

How do you run multiple tasks in parallel on Codex Cloud?

Running multiple tasks in parallel on Codex Cloud means opening multiple tasks from the same published environment, where each task has its own workspace so they don't overwrite each other's files. From the terminal, the codex cloud subcommand (marked EXPERIMENTAL in codex --help version 0.162.1, running on 03/11/2026) has the commands exec, status, list, diff, apply. The codex cloud exec command requires the --env flag to specify the environment, has --branch to choose a branch, and --attempts to run multiple attempts for the same task (best-of-N), defaulting to 1. The syntax according to --help:

codex cloud exec --env <ENV_ID> --attempts 2 "Fix test errors in the api folder"
codex cloud diff <TASK_ID>
codex cloud apply <TASK_ID>

Multiple attempts are useful for comparing two approaches but consume extra quota; we haven't verified the consumption rate. Tasks running in parallel that edit the same file will collide when merging, so divide tasks by different code regions; see the post multiple AI sessions fixing one project.

How do you review pull requests created by Codex safely?

Reviewing pull requests created by Codex safely means treating it like a PR from a new team member: read line by line, run checks again, don't merge just because the summary sounds reasonable. The documentation notes that Codex returns a response, diff, and command log, and you ask it to fix things before opening a PR. OPCAIOS's suggested process, not OpenAI's requirement:

  1. Reread the original task description, then check if the diff does exactly that and nothing else.
  2. Scan for unfamiliar files: new scripts, CI changes, configuration, lockfile; files outside scope are a sign to ask again.
  3. Read the command log, pay attention to network calls and failed commands that the summary skips.
  4. Run tests again on your CI, don't just trust "tests have run".
  5. Scan for secrets and sensitive data written into the code.
  6. Enable branch protection on GitHub: require review and checks before merge.
  7. Add another review round, for example comment @codex review on the PR via the GitHub integration page; the documentation says review rules don't replace tests, branch protection, or human reviewers.

Details in the post using Codex to review code.

When should you push tasks to the cloud instead of running locally?

Situation Choose Reason
Long task, want to sleep Cloud Keeps running when machine sleeps
Many independent tasks, same setup Cloud Each task has its own workspace
Need files or services only on your machine Local Cloud only sees the repo
Sensitive code, contract forbids code leaving the machine Local Source will leave your machine
Need browser, Computer Use, or GitLab repo Local Cloud doesn't support it yet

The table is guidance. Running automation locally or on CI is in the post codex exec running automatically.

What risks come with using Codex on the cloud?

Risks with Codex on the cloud fall into two groups: your source code leaves your machine, and the agent is led astray by strange content like issues, README, or websites. The page "Codex Cloud (Legacy): internet access" (read 03/11/2026) lists risks when you enable internet for the agent: prompt injection, code or key leaks, downloading malware or dependencies with bugs, pulling in content with license issues. The documentation gives an example of a GitHub issue hiding a command to send the latest commit to an outside server; if the agent follows it, data leaks. Ways to reduce risk:

  1. Enable network at the needed level: prioritize Package managers preset, add domain names one by one.
  2. Read issues from strangers yourself before handing them to the agent.
  3. Use network secret instead of environment variables for service call keys.
  4. Check data policy of packages and your company before pushing customer code up; this part is reference only, not legal advice.

General principles are in the post security when using AI to write code.

OPCAIOS's Experience

I haven't used Codex on the cloud to open pull requests, and I haven't run codex exec in CI or GitHub Actions. I use Codex through the CLI version 0.162.x and the desktop application on my main workstation, where each task from the desktop application creates a separate work directory by day, alongside Claude Code and Google Antigravity. Because of this, I don't have any metrics on cloud PRs. The most real lessons come from having multiple agents work on one system: each session commits only its own files, some projects only get edited on one specific machine, and there was once a time when over 1,500 files were reported as changed just because of line ending types when one agent deployed from a Windows machine.

Frequently Asked Questions

Does Codex on the cloud need my computer to be on?

No, according to Codex documentation as read on 03/11/2026: cloud work runs in OpenAI's virtual machines and continues even after your machine has gone to sleep. You can open the same task again from the web, phone, or desktop to see progress or request further edits. Only creating a new environment can be done on the web or desktop application, not on the phone.

Does Codex Cloud automatically merge pull requests into the main branch?

According to the documentation, Codex returns a diff and test results, but you decide whether to commit or open a pull request. When called in a PR using @codex through GitHub integration, Codex can push edits to the PR branch if it has permission. For this reason, you should enable branch protection on GitHub, requiring review and checks before merge, so no changes reach the main branch without going through a person.

Is it safe to put API keys into Codex Cloud?

It's safer if you use network secrets instead of environment variables. According to the Cloud environments page, the program only sees placeholder values, with the proxy substituting the real key when calling the correct allowed domain over HTTPS port 443. Environment variables can be read directly by the program and agents. Whichever way you choose, use keys with narrow permissions, dedicated to the test environment, and revocable.

Can Codex Cloud work with GitLab?

According to the Cloud environments page as read on 03/11/2026, cloud environments don't yet support self-hosted GitLab and GitHub Enterprise Server, and this is a roadmap item. The documentation table of contents has one page on GitLab integration labeled Beta, but I haven't read that page so I can't verify its scope. If your repository is on GitLab, for now use Codex CLI or the desktop application on your machine.

Should someone working alone use Codex on the cloud?

Worth trying when you have a long, independent task, your repository already has tests, and you're ready to carefully read diffs. Not worth it if the code contains sensitive customer data or you're not yet comfortable reviewing pull requests. Start with a small task on a test repository. If you want someone to guide you through a workflow for working with AI agents on real tasks, check out OPCAIOS's AI application training course.

Source: OpenAI's Codex documentation, the pages "Codex Cloud", "Cloud environments", "Codex Cloud (Legacy)", "Codex Cloud (Legacy): internet access" and "Review GitHub pull requests with Codex" (developers.openai.com/codex redirects to learn.chatgpt.com/docs), plus codex cloud --help version 0.162.1, as read on 03/11/2026; have not verified consumption limits and which plans can use Codex Cloud; since I haven't used Codex on the cloud, the PR review process is a suggestion. The experience is OPCAIOS's.

Translated from Vietnamese with AI. Read the original.

Want to apply this in your business?

Book a free 30-minute call (Vietnam time, in English or Vietnamese).

Book a call