Running Claude Code and Codex in the Cloud Without Owning the Infrastructure
Self-hosted agents keep code and secrets on-premises while delegating intelligence to the cloud.

Running Claude Code and Codex in the cloud without owning infrastructure means delegating execution to a managed environment that keeps working after a developer disconnects and returns a reviewable pull request. A bring-your-own API key cloud coding agent runner must also work with the team’s own Anthropic or OpenAI credentials. The deciding factors are session lifetime, environment access, and visibility into what each run costs and produces.
Why running agents locally has a ceiling that cloud infrastructure removes
A developer closes a laptop, the machine sleeps, and the local agent stops before its task is complete. Work loses its running session. An agent tied to the editor process cannot continue independently of that process, regardless of how well it generates code. Large refactors, multi-file changes, and flaky CI investigations can take longer than a developer has at their desk. That dependency limits what can reasonably be delegated.
The session continues after disconnection, finishes the work, and opens a pull request for later review. The workflow becomes asynchronous rather than continuously interactive. This changes the scope of a useful assignment.
The two infrastructure paths Claude Code and Codex have taken
OpenAI’s Codex uses a fully cloud-delegated model, running codex-1, a fine-tuned o3 model, in OpenAI-managed isolated containers. The sandbox edits the repository and runs tests, then returns a pull request with the full command log. Execution has two distinct phases. Setup can use the network to install the specified dependencies, but the agent phase runs offline unless internet access is explicitly turned on. Environment secrets are there for setup and removed before the agent runs, and a person cannot interrupt it mid-task.
In its August 6, 2026 announcement, Anthropic introduced a public beta of self-hosted Claude Code environments for Claude Team and Enterprise organizations, with the feature switched off by default. Sessions run on servers inside the customer’s network. Repository checkouts, build artifacts, secrets, and created or modified files stay on those machines, while the conversation and model inference go to Anthropic’s API. A stored transcript allows a session to be resumed from any surface. Teams can also use Claude models through Amazon Bedrock with identity-and-access-management-based authentication or through Google Vertex AI with Application Default Credentials, with costs tracked through their existing cloud billing.
How self-hosted Claude Code runner infrastructure actually works
An organization creates named environments in claude.ai admin settings, each of which groups long-lived runner processes that run inside its network. A developer selects an environment when starting a cloud session, and Anthropic’s control plane queues the work. A runner with capacity claims the session. It then clones the repository with deployment-provided credentials and starts a Claude Code process on its host. The pattern resembles CI infrastructure, with the organization responsible for building and maintaining the runner image and operating the fleet.
Fixed mode keeps a set number of runners ready at all times for a steady workload. On-demand mode uses an orchestrator to start runners as sessions arrive and stop them when work finishes, making it more cost-efficient for bursty use. Ownership is isolated at the runner level. A runner serves one user at a time and locks to that owner when claiming its first session, preventing checked-out code from mixing between owners. If polling stops for an extended period, the server requeues the session to another runner.
All traffic to Anthropic uses outbound HTTPS to api.anthropic.com, with support for corporate egress proxies and no inbound connection from Anthropic. Coordination also extends beyond a single host. Claude Code v2.1.224, released August 7, 2026, added SendMessage and ListAgents so sessions on different machines can work together. A long-running refactor can therefore coordinate with shorter-lived sessions handling subtasks without the external workarounds previously needed.
Why compliance and internal access drive the self-hosted choice, not just preference
Faire’s senior engineering manager George Jacob explained why the company uses it. “Self-hosted environments let us integrate Claude Code into our existing development workflows while maintaining our security and operational controls. This setup means Claude can generate PRs, help fix CI issues, and respond to developer workflow events, with compute that can scale based on demand.” Anthropic said the organizations in the preview chose this approach for three reasons: access to internal services, pre-installed tooling, and keeping source code and build artifacts in-house.
For organizations in financial services, healthcare, government contracting, or subject to data residency requirements, self-hosting offers an alternative to accepting hosted data handling or losing session portability locally. Remote Control exposes a session on a developer’s own machine through a phone or browser, and the session ends when that machine stops. Shared runners instead belong to infrastructure operated by a platform team and available across the organization.
The beta is limited to Team and Enterprise, excludes zero-data-retention organizations, and leaves inference with Anthropic. Claude Security and Code Review sessions do not yet route to self-hosted environments. Claude Tag sessions can use them but cannot yet use Access bundles there. Anthropic’s hosted offering is still the default for teams whose network, tooling, or compliance needs do not call for running their own runners.
Where Codex's sandboxed cloud model differs and what that tradeoff means in practice
Codex removes the runner-image and fleet responsibilities from the team. Its offline-by-default agent phase prevents unexpected outbound calls while that default remains in place, and setup-only secrets reduce the blast radius of a compromised session. The boundary also restricts the work environment. The agent needs internet access explicitly turned on to reach internal services while it runs, comes with no pre-installed internal tooling, and cannot be interrupted mid-task.
Cost and benchmark performance present another tradeoff. The Coding Agent Index v1.5 places Codex with GPT-6 Sol at 56.7 and Claude Code with Opus 5 at 59.7, with Claude Code having the higher average cost per task. Neither measure describes environment fit on its own. A team optimizing task cost can reach a different conclusion from one optimizing benchmark score.
OpenAI’s September 29, 2026 DevDay updates introduced reusable development environments, moving beyond a separate ephemeral sandbox for each task. Approved settings and permissions can become shared workspace properties. The environments are designed to start tasks faster, while developers can use Codex from a computer, remotely from a phone, or in the cloud. This narrows the configurability gap without making the two infrastructure models identical.
How OpenCode and Cursor fit into a cloud agent stack alongside Claude Code and Codex
OpenCode is a free, MIT-licensed terminal agent that connects to dozens of providers with a user-supplied key or through a paid hosted tier. Its strength is model flexibility without a single provider’s pricing commitment. The same index places OpenCode with GLM-5.3 at 53.6, with a lower average task cost than either Claude Code or Codex.
Cursor handles inline work, Claude Code or OpenCode handles deep terminal-based refactors, and Codex can provide fully asynchronous delegation. Claude Code and OpenCode support human interruption, unlike Codex. Parallelism also differs, as Codex handles multiple simultaneous tasks while Claude Code runs one session at a time without Projects. Anthropic’s September 17, 2026 Projects public beta let select Pro and Max users who were using cloud sessions and had no existing web or desktop projects run cloud sessions in parallel, but used up their existing plan limits faster.
A harness-agnostic environment lets teams keep those roles as models get better. OpenCode’s user-supplied-key support establishes how models are accessed, but that alone does not supply the managed environment in which a cloud session runs.
How Slack, Linear, and GitHub integrations turn cloud agents into a team workflow rather than an individual tool
A Slack thread can become the starting point for delegated coding work. An @Claude mention triggers a cloud-based Claude Code instance that gathers chat context, performs the task, and generates a pull request. Smaller bugs can therefore move from discussion to review without an engineer leaving Slack to supervise execution. GitHub is where the team reviews the work, which can now start elsewhere. The integration connects the request to a team-visible result.
Linear launched coding sessions in June 2026, allowing Linear Agent to write code through Claude Code or Codex in a managed sandbox and draft a pull request. By October 2026, issues could enter coding workflows through direct tool opening, hosted MCP read and write access, cloud agents in the agent directory, delegation to Linear itself, or a label-driven harness. Orchestration can also be managed separately from compute. OpenAI’s September 10, 2026 Agents API provides a hosted Codex harness for orchestration, long-running sessions, and tool use, while teams choose OpenAI-managed compute, their own infrastructure, or sandbox partners.
The team-level benefit depends on attribution. An agent-generated pull request has a traceable origin in its triggering surface, agent, and model. That connection makes shipped work measurable and helps teams refine which tasks they delegate. Engineers still steer and review the work while the agent runs in the background.
What context rot does to long-running agent sessions and how teams manage it
Context rot occurs when prior exchanges accumulate in a running session’s context window and weaken its reasoning about the current task. Repeated work loops increase that accumulation. In multi-agent workflows, an already crowded orchestrator context can also undermine subtask coordination. Persistent compute therefore needs a way to separate durable task state from temporary reasoning context.
The established solution is to run the loop in bash, starting each iteration with a fresh context window rather than repeating everything inside one persistent session. Shared state can live in MEMORY.md or PROGRESS.md files, or in an MCP-based memory server. SendMessage and ListAgents complement this pattern by allowing longer-running sessions to coordinate shorter-lived workers, distributing context load instead of concentrating every exchange in one session.
What enterprise teams are actually getting from cloud agents at production scale
Shopify runs Claude Code at production scale and aims for a high level of autonomous coding, while Mercado Libre aims for a high rate of autonomous coding across its large engineering organization. Uber and Netflix were also cited at the Code with Claude 2026 conference. Those deployments establish adoption. Salesforce expects to spend close to $300 million on Anthropic tokens in 2026, mostly for coding work, and cited engineering productivity gains as the reason for a hiring freeze on net new engineers.
That spending reflects a different cost structure from inline completion. Tools such as Copilot and Cursor Pro charge a flat monthly fee for each engineer, while agentic Claude Code usage has token costs that rise as teams run more tasks and longer sessions. Evaluation needs to follow completed work. Teams weighing return on investment should measure how much of each task gets done, how many pull requests get through, and how much less often senior engineers are interrupted, rather than lines of code or how fast each developer works.
How do teams run cloud agents without managing their own infrastructure?
A managed cloud agent environment runs the work so the engineering team does not have to run a runner fleet. Pre-configured, isolated VMs can provide dependencies, per-session sandboxing, and full run attribution. Those capabilities address three distinct criteria, namely whether the session can outlast the workday, whether its environment has the required dependencies and access, and whether the team can see execution, cost, and output.
For a buyer seeking a cloud platform that uses an existing Anthropic or OpenAI API key, credential support is an additional selection criterion. The platform must support the intended harness and credential path as well as the required execution environment. A key does not operate the infrastructure. An agent can then continue independently, work within the right boundaries, and return something engineers can merge without making them responsible for the machines underneath it.


