OpenCode vs Codex in CI the Hidden Infrastructure Tax Teams Pay Before a Single Line Runs
Harness, environment, and compute each add costs the subscription price hides.

Running OpenCode or Codex in CI means paying for a harness, an execution environment, and compute. OpenCode puts environment and runner ownership with the team, while Codex Cloud supplies them as managed infrastructure. The hidden infrastructure tax grows as those layers grow together, and governance adds costs that stay hidden in the subscription price and a successful demo.
The three infrastructure layers every CI agent run crosses
The harness supplies the agent loop and tool scaffolding. The environment supplies the sandbox or VM, repository checkout, dependencies, and access the agent needs to work. The compute platform provisions the machine and runs its billing clock. These are separate responsibilities, even when one vendor bundles them. Every CI agent run crosses all three before agent-written code executes.
A dependency cache belongs to the environment, while the machine time spent rebuilding it belongs to compute. A harness can orchestrate work without supplying either. Because decisions at one layer constrain the next, a comparison that stops at agent features misses the infrastructure needed to turn those features into working pull requests.
What the harness layer actually is and what OpenCode and Codex each bring to it
OpenCode uses a client-server architecture, with a Go TUI and a Bun/TypeScript HTTP server. Terminal, desktop, IDE, and web frontends connect to the same engine. Its working surface is the developer’s existing environment. Git-based snapshots support /undo and /redo, while Plan mode permits read-only work and Build mode permits full access. Inside GitHub Actions runners, it can triage issues, implement changes, create branches, and open pull requests.
Version differences affect what that loop can do. OpenCode V1 feeds compiler diagnostics from language servers back into the agent after edits, enabling self-correction. V2 accepts LSP configuration but does not run language servers or produce LSP diagnostics. As of v2.3.0, subagents run in the background by default and report back when idle, allowing parallel work while the user remains in the parent session.
Codex also has a full harness, with its tool loop, session management, and orchestration. Its delivery model differs. Codex Cloud is a managed service, while Codex CLI is a self-hosted binary. In the cloud service, tasks run asynchronously in fresh isolated environments, and separate sandboxes let teams submit tasks in parallel. The service clones the repository, makes changes, runs tests, and opens a PR, notifying the team when it is ready.
OpenAI’s Agents API announcement positions long-running sessions and context management as rentable infrastructure, sparing teams the work of rebuilding that machinery. That framing makes the architectural distinction explicit. OpenCode runs against the filesystem, shell, and git remotes the team supplies. Codex Cloud includes an execution environment in its managed model, moving the comparison beyond what either harness can do alone.
The environment layer and what gets provisioned before the agent writes anything
An agent needs a prepared workspace before it can act. That includes its sandbox or VM, dependency cache, secrets configuration, and repository checkout. For OpenCode in CI, the team supplies this environment through its runner infrastructure. Provisioning work therefore remains an engineering responsibility, and the wall-clock time it consumes remains part of each run. Rebuilding a cold dependency cache is a concrete expense incurred before the agent writes a character.
Control is the return on that work. The team controls the runner’s code, build artifacts, and secrets, as well as how the environment is maintained. Enterprise mode adds centralized configuration and internal AI gateway routing so the team can control which models and endpoints agents can reach. Those controls give the team ways to govern an environment it still owns and must provision.
Codex Cloud instead offers a reusable cloud environment that bundles repositories, dependencies, tools, and access settings. Tasks can clone that object. Reuse avoids rebuilding the environment from scratch but creates an environment that must be configured, versioned, and paid for beyond the harness subscription. Because execution has no outbound internet access, dependencies must be available before the task starts. Repository access and secrets also have to be granted during setup.
Teams with existing CI runners still have to do this work. Agents need longer-lived context, iterative test execution, and access patterns that human-authored pipelines may not anticipate. Both approaches therefore need to be configured for agent autonomy as well as to give the process a place to run. This is where the cost profiles diverge most sharply. Codex externalizes provisioning and charges for it, while OpenCode leaves the work with the team.
The compute layer and who controls the billing clock
With compute, teams also have to know when billing starts, how long resources stay active, and who can release them. Time spent preparing dependencies occupies infrastructure before code generation begins. That makes compute a structural expense rather than an incidental surcharge on successful agent work.
OpenCode’s harness incurs no charge while idle, and the team’s provider keys pay for inference tokens consumed during active work. Runner costs follow a different clock. An idle harness does not make its host infrastructure free, and parallel tasks require runner concurrency the team has purchased or can provision. Scaling agent work therefore means scaling CI capacity deliberately. The exposure is visible within infrastructure the team controls, but that control comes with capacity planning.
Codex Cloud moves that responsibility to OpenAI’s infrastructure. Its compute uses microVMs billed through the Codex or Agents API pricing tier, allowing engineers to submit parallel tasks without managing runner concurrency themselves. Independent environments make concurrency convenient, but active tasks accumulate machine time simultaneously. With the asynchronous model, there is no interactive session whose end marks when the work is done. Billing exposure follows how many tasks are running and how long they take.
How the three layers compound and why the subscription is not the total
The gap between the advertised tool cost and actual CI spending follows from how the layers interact. More tasks require more environment boots or cloud environment management, more concurrent compute, and more inference. A workflow that lets teams submit tasks faster can therefore use more infrastructure without the same rise in how much output gets reviewed.
Low volume can conceal that relationship for a while. With a handful of tasks per week, the cost of provisioning time may be too small to stand out in a runner budget. At higher volume, the same preparation work repeats across more runs, while parallel execution increases simultaneous resource use. The setup that appeared negligible in a demo becomes a recurring part of operating the system. Nothing needs to malfunction for the difference to appear.
OpenCode’s runner costs sit with CI infrastructure, while Codex’s managed costs accumulate within OpenAI’s billing, which teams may inspect less frequently than pipeline dashboards. Meanwhile, asynchronous task submission can outpace the team’s PR review cadence. Budget caps help only within their scope. A harness spending limit does not constrain provisioning on CI runners or compute on self-managed infrastructure, so one capped bill is not a capped architecture.
How should teams choose between OpenCode and Codex in CI?
Teams with scalable CI runners and engineering capacity to maintain agent environments have a clear reason to consider OpenCode. It lets runner spending remain in the same dashboards as the rest of their pipeline infrastructure. In exchange, the team accepts responsibility for provisioning, dependency preparation, and concurrency. Existing infrastructure is an advantage only when the team can support the additional work.
Codex’s managed model fits a different operating preference. Teams seeking faster time-to-first-PR without owning environment provisioning and compute management can externalize those responsibilities to OpenAI. That choice also requires comfort with asynchronous, non-interactive submission and parallel execution. The team’s compliance requirements must allow code to run in vendor-managed, network-isolated sandboxes. Managed isolation addresses some security requirements, but it does not decide whether that deployment model is acceptable for a particular repository.
Portability cuts across both sets of criteria. When a workflow is tightly tied to Codex’s task API, cloud environment format, and PR notification model, switching adds costs on top of the infrastructure bill. With OpenCode’s open-source, model-agnostic harness, the cost of switching at the harness layer is near-zero, but someone still has to own the environment. Neither side removes the need to account for the layers below the tool.
The governance costs above all three infrastructure layers
Credential management, audit logs, access controls, and compliance documentation give the team more work to do. Governance sits above the three infrastructure layers because it governs what each may do. Its cost grows with agent parallelism, repository sensitivity, and organizational requirements. For either harness, it is work that has to be budgeted separately from the subscription.
For OpenCode, provider keys must be injected securely into whichever CI runners use them. Model-agnostic workflows require credentials for each selected provider, making credential scope an ongoing concern. Centralized configuration and internal gateway routing can reduce per-project sprawl, but maintaining the gateway is itself an engineering task. Session sharing adds a separate policy decision. Sharing is opt-in through /share, yet shared links are public to anyone holding them, so sharing should be disabled for sensitive work.
With Codex, the team decides on access when it sets up the environment. The team grants repository access and secrets to a vendor-managed environment and must revisit those grants when secret rotation policy changes. Network isolation does not settle what the VM should be permitted to see. Because work is asynchronous, people review the resulting PR. Audit coverage depends on what the diff and OpenAI’s logging surface expose.
Unless governance is built into the platform, parallel work across repositories adds credentials, access grants, and audit points faster than it adds speed. The full infrastructure tax includes the harness, the environment, compute, and governance. That leaves four layers and four bill owners behind one velocity number in a demo. Teams that map all four before scaling are better positioned to sustain that velocity.
Mapping the tax before scaling and what an honest audit looks like
An honest audit replaces single-task extrapolation with questions about the system that will operate at scale. At the harness layer, it asks what the workflow is coupled to and what changing agents would require. OpenCode’s portability and Codex’s integrated submission, environment, and PR delivery surfaces create different answers. The distinction belongs in the architecture decision before workflows depend on it.
At the environment layer, the audit identifies who provisions the workspace, who maintains it, and what happens when a dependency changes. An owned runner environment assigns that work to engineering. With a Codex cloud environment, the team depends on the vendor and has to prepare the environment before network-isolated execution starts. The audit must establish when billing starts, when it stops, and who can stop it, because asynchronous work can continue until completion or timeout without an interactive session.
Governance completes the audit by establishing what the agent can touch, what record exists of its actions, and who can revoke access. The answer should be a system design. That design needs isolated task environments that produce pull requests people can review, along with parallel execution that scales on demand. Credentials and access must also be auditable and rotatable without changing the agent workflow.


