Skip to content

Fix Codex config generation for current @openai/codex#7

Open
cplegendre wants to merge 2 commits into
redhat-et:mainfrom
cplegendre:fix-codex-current-config
Open

Fix Codex config generation for current @openai/codex#7
cplegendre wants to merge 2 commits into
redhat-et:mainfrom
cplegendre:fix-codex-current-config

Conversation

@cplegendre

@cplegendre cplegendre commented Jul 3, 2026

Copy link
Copy Markdown

Summary

This PR updates the Codex helper config generation to avoid the legacy Codex profile format that is rejected by current @openai/codex releases.

Previously, the generated config.toml used the legacy top-level profile selector:

profile = "custom-vllm"

and a legacy profile section:

[profiles.custom-vllm]

Current Codex CLI rejects this format and exits before producing a Codex session.

Problem

When running coding-agent-bench with --agent codex and a local OpenAI-compatible server, the benchmark installs Codex with:

npm install -g @openai/codex@latest

With the current Codex CLI, the generated config fails with:

Error: legacy `profile = "custom-vllm"` config is no longer supported; use `--profile custom-vllm` with `custom-vllm.config.toml` instead

The benchmark then reports:

No Codex session directory found
NonZeroAgentExitCodeError

Change

This PR updates src/coding_agent_bench/helpers/codex.py so the generated config uses the current direct provider format instead of the legacy profile format.

The generated config now uses:

model = "..."
model_provider = "vllm"

[model_providers.vllm]
...

instead of:

profile = "custom-vllm"

[profiles.custom-vllm]
...

Tested

Tested locally on macOS with Docker Desktop, Ollama, and the Codex agent.

Models tested:

  • qwen2.5-coder:7b
  • qwen3-coder:30b

Dataset:

swe-bench/swe-bench-verified

Command used:

uv run coding-agent-bench run \
  --agent codex \
  --dataset swe-bench/swe-bench-verified \
  --model-name qwen3-coder:30b \
  --server-url http://host.docker.internal:11434 \
  --n-tasks 1 \
  --n-concurrent 1

Docker connectivity to Ollama was verified with:

docker run --rm curlimages/curl:8.10.1 \
  http://host.docker.internal:11434/v1/models

Result

Before this change:

Exceptions: 1
Exception: NonZeroAgentExitCodeError
No Codex session directory found

After this change:

Exceptions: 0
Wrote Codex trajectory
Reward: 0.0

The reward remained 0.0, but the benchmark infrastructure and Codex agent execution completed successfully. This suggests the issue was the generated Codex config format, not Docker, Ollama connectivity, or the verifier.

Summary by CodeRabbit

  • Bug Fixes
    • Improved how connection settings are generated so server addresses with trailing slashes are handled correctly.
    • Updated agent configuration output to use a more direct model setup, reducing the chance of invalid or inconsistent settings.

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@cplegendre, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 9db432db-1f21-4887-817b-bb8ef7d1d2fd

📥 Commits

Reviewing files that changed from the base of the PR and between 078d71d and e115eae.

📒 Files selected for processing (1)
  • src/coding_agent_bench/helpers/codex.py
📝 Walkthrough

Walkthrough

The TEMPLATE constant in codex.py was modified to embed model and model_provider settings directly instead of using a profile-based configuration, and the associated profile section was removed. Additionally, codex_create_toml now strips trailing slashes from server_url before formatting.

Changes

Codex TOML Generation Update

Layer / File(s) Summary
Inline model config and URL normalization
src/coding_agent_bench/helpers/codex.py
TEMPLATE now embeds model and model_provider directly, replacing the profiles.custom-vllm block, and codex_create_toml strips trailing slashes from server_url before formatting into TEMPLATE.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: updating Codex config generation for current @openai/codex releases.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
src/coding_agent_bench/helpers/codex.py (1)

22-22: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Unescaped interpolation into TOML string.

model_name and server_url are interpolated into a TOML-formatted string via .format() without escaping quotes/special characters. Per the referenced CreateJobRequest in src/coding_agent_bench/api.py, both values originate from an external API request body, so a value containing a " would produce invalid/broken TOML (or in principle alter adjacent keys).

🛡️ Suggested fix using a TOML-safe encoder
+import tomlkit
+
 def codex_create_toml(model_name: str, server_url: str, outpath: Path):
-    toml = TEMPLATE.format(model_name=model_name, server_url=server_url.rstrip("/"))
+    toml = TEMPLATE.format(
+        model_name=tomlkit.string(model_name).as_string(),
+        server_url=server_url.rstrip("/"),
+    )

Also flagging the static analysis hint on Line 23 (open(outpath, "w")) as a likely false positive here, since outpath is constructed internally (e.g. Path("config.toml").absolute() in configs.py) rather than taken directly from request input.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/coding_agent_bench/helpers/codex.py` at line 22, The TOML template
interpolation in codex.py is unsafe because model_name and server_url come from
CreateJobRequest and are inserted into TEMPLATE via .format() without TOML
escaping. Update the code path that builds toml so these values are serialized
with a TOML-safe encoder or otherwise properly escaped before formatting, and
keep the open(outpath, "w") usage unchanged since outpath is internally
constructed and not user-controlled.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/coding_agent_bench/helpers/codex.py`:
- Line 22: The TOML template interpolation in codex.py is unsafe because
model_name and server_url come from CreateJobRequest and are inserted into
TEMPLATE via .format() without TOML escaping. Update the code path that builds
toml so these values are serialized with a TOML-safe encoder or otherwise
properly escaped before formatting, and keep the open(outpath, "w") usage
unchanged since outpath is internally constructed and not user-controlled.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: b316313a-fe19-4336-8a03-e82365d0e9d5

📥 Commits

Reviewing files that changed from the base of the PR and between bc0a670 and 078d71d.

📒 Files selected for processing (1)
  • src/coding_agent_bench/helpers/codex.py

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.

1 participant