Skip to content

feat(codex): add codex as a native benchmark agent - #2

Closed
arielnabavian wants to merge 2 commits into
notowen333:harbor-adapterfrom
arielnabavian:arielnabavian/add-codex-agent
Closed

arielnabavian wants to merge 2 commits into
notowen333:harbor-adapterfrom
arielnabavian:arielnabavian/add-codex-agent

Conversation

@arielnabavian

Copy link
Copy Markdown

Summary

Adds Codex (OpenAI's Codex CLI, harbor.agents.installed.codex:Codex) as a fourth native agent alongside Stan, Claude Code, and OpenCode. Routes through Bedrock Mantle's OpenAI-compatible /openai/v1 endpoint using the same bedrock_api_key secret OpenCode and TAU3 already consume.

The doc's target grid lists GPT-5.6 Sol as one of the six models. Currently the only harness we can run against GPT is OpenCode. This PR unblocks Codex × GPT cells (5 cells against the doc's 5 benchmarks) and makes Codex available for the composite Index as well.

Changes

  • run-benchmark.sh: new codex) agent case + codex) model-routing case + configure_codex_mantle function. CODEX_VERSION is required (Codex's release cadence is fast enough that unpinned installs would produce empty @ segments in job names). Model gate rejects non-GPT with a clear error, mirroring Claude Code's Anthropic-only gate.
  • run.py: Codex added to _native_agents, plus an env-forwarding branch that plumbs OPENAI_API_KEY and OPENAI_BASE_URL (from CODEX_OPENAI_BASE_URL) as --ae templates. Harbor resolves the templates at construction and stores references, not secret values, in job config.
  • run-matrix.sh: Codex recognized as native; compatibility check rejects codex + non-GPT cells up front so matrix runs list them as INCOMPATIBLE_CELLS; CODEX_VERSION gets baked into the matrix state id.
  • README.md and ORCHESTRATOR.md: agent tables list codex, env-var table documents CODEX_VERSION, new example, native-competitor section describes the Mantle wiring and GPT-only constraint.

Harbor's Codex adapter (upstream) is used unchanged — it already reads OPENAI_API_KEY/OPENAI_BASE_URL via ModelConnectionSpec(default_provider="openai").

Not touched

  • run-full-native-suite.sh — its default AGENTS="claude-code,opencode" stays. Adding Codex silently would kick off unplanned baseline runs.
  • Harbor fork — no changes needed there.

Verification

  • bash -n run-benchmark.sh clean; python3.12 ast.parse clean on run.py.
  • BENCHMARK_DRY_RUN=1 CODEX_VERSION=0.118.0 bash strands-infra-runner/run-benchmark.sh codex openai.gpt-5.6-sol swe-bench/swe-bench-verified 4 produces the correct job name, S3 prefix, and Mantle URL.
  • BENCHMARK_DRY_RUN=1 CODEX_VERSION=0.118.0 bash strands-infra-runner/run-benchmark.sh codex sonnet-4.6 … rejects with the expected error.
  • HARBOR_DRY_RUN=1 inspection of run.py output confirms harbor run argv includes -a codex -m openai.gpt-5.6-sol --ak version=0.118.0 --ae OPENAI_API_KEY=${OPENAI_API_KEY} --ae OPENAI_BASE_URL=${CODEX_OPENAI_BASE_URL}.

Usage

env CODEX_VERSION=0.118.0 bash strands-infra-runner/run-benchmark.sh codex openai.gpt-5.6-sol swe-bench/swe-bench-verified

Job name pattern: codex@<version>--openai.gpt-5.6-sol--<dataset-slug>.

Open questions

  • Version pin — I made CODEX_VERSION required rather than defaulting like CLAUDE_CODE_VERSION=2.1.220 and OPENCODE_VERSION=1.18.9. Happy to default to a known-good pin if you have one in mind; I didn't want to guess.
  • Should Codex be added to run-full-native-suite.sh's default agent list in a follow-up? Not doing that here — separate decision.

Ariel Nabavian added 2 commits August 12, 2026 16:40
Adds Codex (OpenAI's Codex CLI) as a fourth native agent alongside Stan,
Claude Code, and OpenCode. Runs through Bedrock Mantle's OpenAI-compatible
`/openai/v1` endpoint using the same `bedrock_api_key` secret that OpenCode
and TAU3 already consume.

Changes:

* `run-benchmark.sh`:
  - New `codex)` agent case. `CODEX_VERSION` is required (Codex's release
    cadence is fast enough that unpinned installs would leave the job name
    with an empty `@` segment).
  - New `codex)` model-routing case. Only accepts `openai.gpt*` model IDs;
    hard-rejects everything else with a clear error (mirrors Claude Code's
    Anthropic-only gate).
  - New `configure_codex_mantle` function that loads the Bedrock bearer
    token and exports it as `OPENAI_API_KEY` alongside
    `CODEX_OPENAI_BASE_URL` and `OPENAI_BASE_URL`.
  - Mantle URL line in the run summary.

* `run.py`:
  - Codex added to `_native_agents`.
  - New branch in the env-forwarding block that plumbs `OPENAI_API_KEY` and
    `OPENAI_BASE_URL` (from `CODEX_OPENAI_BASE_URL`) into the fleet as
    `--ae` templates. Harbor resolves templates at agent construction and
    stores references, not secret values, in job config.

* `run-matrix.sh`:
  - Codex recognized as a native agent for the `HAS_NATIVE` flag.
  - Compatibility check rejects Codex + non-GPT combinations up front, so
    matrix runs list them as `INCOMPATIBLE_CELLS` rather than starting a
    doomed cell.
  - `CODEX_VERSION` gets baked into the matrix state id (`codex@<version>`).
  - New usage example.

* `README.md` and `ORCHESTRATOR.md`:
  - Agent tables list `codex`.
  - `CODEX_VERSION` documented in the env-var table.
  - New Codex example under Full examples.
  - Native-competitor section describes the Mantle wiring and the GPT-only
    constraint.

Harbor's Codex adapter (`harbor.agents.installed.codex:Codex`) is used
unchanged — it already reads `OPENAI_API_KEY`/`OPENAI_BASE_URL` through its
`ModelConnectionSpec(default_provider="openai")`.

Verified with `BENCHMARK_DRY_RUN=1` and `HARBOR_DRY_RUN=1`:

* Valid model: correct job name, correct S3 prefix, correct `harbor run` argv
  (with `--ae OPENAI_API_KEY=${OPENAI_API_KEY}` templates).
* Invalid model (non-GPT): rejected with clear error.
* `bash -n` clean; run.py parses under Python 3.12.

Not touched: `run-full-native-suite.sh`'s default `AGENTS="claude-code,opencode"`
— adding Codex silently would kick off unplanned baseline runs. Opt-in.
Follow-up to PR feedback: pin a default version so identical invocations of
run-benchmark.sh produce identical Codex CLI installs across runs. Matches
the pattern already established for CLAUDE_CODE_VERSION (2.1.220) and
OPENCODE_VERSION (1.18.9). Users can still override via the env var.

0.147.0 is the current npm `@openai/codex@latest` stable at PR time.

@mkmeral mkmeral left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to yolo lol

@mkmeral mkmeral left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to yolo lol

@arielnabavian

Copy link
Copy Markdown
Author

I don't have permission to merge this. 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants