OpenCode, Codex and the harness2-bridge Executor Guide
Last updated: October 19, 2026
How OpenCode and Codex (--substrate cx) work in Harness², how to run harness2-bridge for Vertex AI Gemini, configure HARNESS2_CODEX_* variables, and expose the bridge to Docker.
Harness² refines the eight harness components while keeping model weights fixed, and it executes those harnesses through an underlying executor substrate. The official release supports two executors across all three benchmarks (LAB, JobBench and WorkBuddy-Bench) and both recursion modes (parallel and sequential): OpenCode by default, and Codex via --substrate cx.
OpenCode vs Codex (--substrate cx)
Choosing between OpenCode and Codex determines which model API protocol the executor speaks, how .env variables are routed, and how containerized benchmarks reach the model endpoint.
| Executor | CLI Selection | Model Format / API | Config Location | Container Behavior |
|---|---|---|---|---|
| OpenCode | Default (no flag needed) | provider/model via HARNESS2_SOLVER_MODEL (for example google-vertex/gemini...) | .env (HARNESS2_SOLVER_MODEL, HARNESS2_IMPROVER_MODEL); WorkBuddy setup generates solver and judge routes | WorkBuddy runs a fresh container per rollout; its job-local proxy refreshes ADC tokens and preserves Gemini thought signatures |
| Codex | --substrate cx (or SUBSTRATE=cx in scripts/run_*.sh) | OpenAI Responses API via HARNESS2_CODEX_* (or Vertex AI Gemini through harness2-bridge) | .env (HARNESS2_CODEX_*), persisted to dependencies/codex/home/config.toml by setup; bridge port/key saved under dependencies/codex/ | WorkBuddy runs Codex inside Docker containers, requiring harness2-bridge --host 0.0.0.0 and HARNESS2_CODEX_CONTAINER_URL |
Per-domain improvement libraries are separated by benchmark, executor, mode, budget and seed. OpenCode and Codex runs never share a continual improvement library, and you must pass --substrate cx consistently across harness2-setup, harness2-check, harness2, harness2-judge and harness2-report.
How harness2-bridge connects Codex to Vertex AI Gemini
The Codex executor expects an OpenAI Responses API endpoint. To run Gemini models on Vertex AI with Codex, Harness² ships harness2-bridge — a local LiteLLM server that exposes a Responses API endpoint backed by your Google Cloud Application Default Credentials (gcloud auth application-default login) and GOOGLE_CLOUD_PROJECT (GOOGLE_CLOUD_LOCATION defaults to global).
Install the optional bridge extra alongside render, then start the bridge in a separate terminal session:
uv pip install -e '.[render,bridge]'
harness2-bridge # for WorkBuddy: harness2-bridge --host 0.0.0.0When harness2-bridge starts, it prints the HARNESS2_CODEX_* settings to add to .env. Its port and generated access key are stored under dependencies/codex/ and reused automatically on restart.
HARNESS2_CODEX_* settings and config.toml persistence
Add the values printed by harness2-bridge — or your own Responses API credentials if you are connecting directly to another endpoint — to .env:
| Setting | Meaning |
|---|---|
HARNESS2_CODEX_BASE_URL | Responses API endpoint URL printed by harness2-bridge (or a direct custom Responses API endpoint) |
HARNESS2_CODEX_CONTAINER_URL | Container-reachable bridge URL printed when harness2-bridge runs with --host 0.0.0.0 for WorkBuddy-Bench |
HARNESS2_CODEX_API_KEY | Generated local access key from harness2-bridge (or your key for a custom Responses API endpoint) |
HARNESS2_CODEX_MODEL | Model identifier sent to the Responses API endpoint |
To connect directly to another Responses API endpoint without harness2-bridge, set HARNESS2_CODEX_BASE_URL, HARNESS2_CODEX_API_KEY and HARNESS2_CODEX_MODEL in .env directly.
Running a --substrate cx workflow
Pass --substrate cx to setup, checks, refinement, judging and reporting:
harness2-setup lab --substrate cx
harness2-check --bench lab --substrate cx
harness2 --bench lab --substrate cx --k 1 --mode parallel \
--only-domains antitrust-competition --max-tasks 1
harness2-judge --bench lab --substrate cx --k 1 --mode parallel
harness2-report --bench lab --substrate cx --k 1 --mode parallelIf you use the convenience runner scripts under scripts/, set SUBSTRATE=cx in the environment:
SUBSTRATE=cx K=3 MODE=sequential bash scripts/run_jobbench.sh --max-tasks 1The stale config.toml trap
harness2-setup <bench> --substrate cx records the configured endpoint and model inside dependencies/codex/home/config.toml. If you later change HARNESS2_CODEX_BASE_URL or HARNESS2_CODEX_MODEL in .env, rerun harness2-setup <bench> --substrate cx. Until you do, harness2-check reports a stale configuration error rather than silently running against the old target.
WorkBuddy-Bench: Docker routing and proxy requirements
WorkBuddy-Bench executes every rollout in a fresh Docker container, which changes how both executors handle authentication and networking.
Codex inside Docker (--host 0.0.0.0)
A bridge bound only to localhost is unreachable from inside a Docker container. Start the bridge with --host 0.0.0.0 and copy the printed HARNESS2_CODEX_CONTAINER_URL into .env:
harness2-bridge --host 0.0.0.0Because --host 0.0.0.0 binds the bridge to all network interfaces on the host, restrict host firewall or network access to intended clients only.
OpenCode on WorkBuddy-Bench
For the public Vertex AI setup with OpenCode on WorkBuddy-Bench, harness2-setup wb enforces strict model format rules: HARNESS2_SOLVER_MODEL must be a google-vertex/gemini... ID, HARNESS2_JUDGE_MODEL must be a bare gemini... ID, and GOOGLE_CLOUD_PROJECT must be set (--dry-run still prints the rest of the plan while reporting the requirement).
Setup generates the solver and judge routes from .env, so rerun harness2-setup wb --subset <subset> whenever either model changes. During execution, WorkBuddy's job-local proxy refreshes Application Default Credentials tokens automatically and preserves Gemini tool-call thought signatures.
Environment scrubbing (SCRUB_ENV) and sandbox security
Token isolation via SCRUB_ENV
Agents and judges launched by Harness² do not inherit the judge, bridge, provider, cloud and host tokens listed in SCRUB_ENV (harness2/config.py). Each process keeps only the key required for its own model call — so a harness tool that expects another listed token, such as GITHUB_TOKEN, does not receive it. Variables not listed in SCRUB_ENV pass through unchanged, and local helpers such as the render bridge still receive the full environment.
Disabled Codex sandbox and rubric leakage
Codex runs with its sandbox disabled, and executor network access is unrestricted in the release. Because JobBench, LAB and WorkBuddy-Bench are public — and JobBench hosts each task's RUBRICS.json on Hugging Face — an unrestricted executor can retrieve grading criteria from the web. The official experiment guide documents a validation run in which a Codex rollout on JobBench downloaded its task's rubric without being instructed to.
After harness2-setup finishes downloading dependencies and datasets, block these hosts at the host network level (egress firewall or DNS policy) before running evaluations, and report the restrictions alongside your results:
huggingface.co,hf.co, and*.hf.cogithub.comandraw.githubusercontent.com
Next steps
- Install — Python 3.12,
uv, Vertex AI credentials and benchmark prerequisites. - CLI Commands — reference for
harness2,harness2-setup,harness2-check,harness2-judge,harness2-reportandharness2-demo. - Benchmarks — LAB, JobBench and WorkBuddy-Bench setup and network restrictions.
- Tutorial — Propose–Probe–Compose,
--kbudgets and choosingparallelvssequential.
Sources
Repository: github.com/google-research/harness2 · Paper: arXiv 2610.14224 · Official site: harness2.github.io
This page is part of an unofficial guide. Where the official docs do not specify something, this page says so rather than guessing.