Skip to content

fix(agents): fall back to PI when Codex harness is unavailable#82532

Merged
steipete merged 2 commits into
mainfrom
fix/codex-harness-pi-fallback
May 16, 2026
Merged

fix(agents): fall back to PI when Codex harness is unavailable#82532
steipete merged 2 commits into
mainfrom
fix/codex-harness-pi-fallback

Conversation

@steipete

@steipete steipete commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fall back to the embedded PI harness when OpenAI's implicit Codex runtime preference cannot find a registered Codex harness.
  • Keep raw harness policy resolution independent from plugin registration so Codex plugin discovery can still run before selection.
  • Keep auth-profile validation/runtime forwarding aligned for Codex runs, including OpenAI API-key backup profiles.
  • Add regression coverage for the fallback, pre-selection Codex plugin load, and Codex auth-profile forwarding.

Fixes #82437

Verification

  • git diff --check
  • node scripts/run-vitest.mjs src/agents/command/attempt-execution.cli.test.ts src/agents/openai-codex-routing.test.ts src/agents/runtime-plan/build.test.ts src/agents/auth-profiles/session-override.test.ts src/agents/harness/selection.test.ts src/agents/harness/runtime-plugin.test.ts src/agents/auth-profile-runtime-contract.test.ts - 13 files, 182 tests passed
  • pnpm check:changed via Testbox tbx_01krr5kvqe3ww5c76fstke63bf - passed
  • /Users/steipete/Projects/agent-scripts/skills/codex-review/scripts/codex-review - clean, no accepted/actionable findings

Behavior addressed: /v1/chat/completions requests using the default OpenAI agent model no longer fail just because the implicit Codex harness preference cannot find the Codex plugin/harness.
Real environment tested: local focused Vitest plus Blacksmith Testbox changed-files gate on the rebased PR branch.
Exact steps or command run after this patch: node scripts/run-vitest.mjs src/agents/command/attempt-execution.cli.test.ts src/agents/openai-codex-routing.test.ts src/agents/runtime-plan/build.test.ts src/agents/auth-profiles/session-override.test.ts src/agents/harness/selection.test.ts src/agents/harness/runtime-plugin.test.ts src/agents/auth-profile-runtime-contract.test.ts; pnpm check:changed.
Evidence after fix: selection tests cover OpenAI implicit Codex preference with no registered Codex harness and assert PI is selected/run; runtime-plugin tests cover pre-selection Codex plugin loading; attempt-execution tests cover OpenAI API-key backup auth forwarding for Codex harness runs; Testbox changed gate passed as tbx_01krr5kvqe3ww5c76fstke63bf.
Observed result after fix: implicit OpenAI Codex runtime preference falls back to PI when Codex is unavailable, while explicit plugin runtime policy still fails closed when the requested harness is unavailable.
What was not tested: full published Docker image smoke for the reporter's exact digest.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels May 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8a994de672

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread CHANGELOG.md
- CLI/context engines: bootstrap and finalize non-legacy context engines for CLI turns while preserving transcript snapshots and deferred maintenance ownership. (#81869) Thanks @sahilsatralkar.
- Telegram: persist polling updates through restart replay so queued same-topic messages resume in order instead of losing context after a gateway restart. (#82256) Thanks @VACInc.
- Gateway/Gmail: abort in-flight Gmail watcher startup and hot-reload restarts before shutdown so reloads cannot spawn `gog serve` after the Gateway is closing. Thanks @frankekn.
- Agents/Codex: fall back to the embedded PI runner when OpenAI's implicit Codex harness preference cannot find a registered Codex plugin, preventing OpenAI-compatible gateway requests from failing with an unregistered harness error. Fixes #82437.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Remove contributor-authored changelog entry

This commit adds a CHANGELOG.md line even though the root contributor policy says changelog entries are maintainer/AI-owned during landing, so including it here violates the repo workflow and creates avoidable merge churn on a high-conflict file; please drop this entry from the contributor commit and let landing automation or maintainers add it.

Useful? React with 👍 / 👎.

@clawsweeper

clawsweeper Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR makes implicit OpenAI-to-Codex harness selection fall back to PI when no Codex harness is registered, adds focused harness-selection coverage, and adds a changelog line.

Reproducibility: yes. source-reproducible: current main resolves official OpenAI defaults to implicit codex and then throws when that harness is not registered. The linked issue supplies the live /v1/chat/completions failure, but I did not rerun the container.

Real behavior proof
Not applicable: The PR is maintainer-labelled, so the external-contributor proof gate does not apply; its body records focused tests/Testbox proof but not a live gateway smoke.

Next step before merge
Continue normal maintainer review; ClawSweeper found no patch-correctness issue.

Security
Cleared: The diff changes harness-selection logic, tests, and changelog text only; it adds no dependencies, CI, secrets handling, downloads, or new code-execution surface.

Review details

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: current main resolves official OpenAI defaults to implicit codex and then throws when that harness is not registered. The linked issue supplies the live /v1/chat/completions failure, but I did not rerun the container.

Is this the best way to solve the issue?

Mostly, but not as submitted: the implicit-only fallback preserves explicit runtime fail-closed behavior and is a narrow code fix. The changelog edit should be removed from the contributor branch and handled during landing.

What I checked:

  • Current main default policy: On current origin/main, official OpenAI provider selection with implicit auto runtime resolves to runtime "codex". (src/agents/harness/policy.ts:38, 46a67d30afa3)
  • Current main failure path: On current origin/main, a non-auto runtime that is not registered throws the reported Requested agent harness "<runtime>" is not registered. error. (src/agents/harness/selection.ts:102, 46a67d30afa3)
  • PR diff: The PR adds an implicit-only Codex-unavailable PI fallback and two regression tests for OpenAI with no registered Codex harness. (src/agents/harness/selection.ts:111, 8a994de672c4)
  • Linked regression context: The linked issue includes a concrete /v1/chat/completions failure and an earlier ClawSweeper source review keeping it open as source-reproducible on the same harness-selection path.
  • Protected label: The PR has the maintainer label, which is protected by the cleanup policy and requires explicit maintainer handling.
  • Existing review comment: A prior Codex review comment already flagged the added CHANGELOG.md line as contributor-authored changelog churn against repo workflow. (CHANGELOG.md:22, 8a994de672c4)

Likely related people:

  • steipete: Peter Steinberger authored recent merged runtime-selection/model-picker work that touched src/agents/harness/selection.ts, runtime-plugin.ts, and model runtime policy; this is separate from being the current PR author. (role: recent area contributor; confidence: high; commits: 6171b4254d41; files: src/agents/harness/selection.ts, src/agents/harness/runtime-plugin.ts, src/agents/model-runtime-policy.ts)
  • joshavant: Blame ties the implicit runtime-source and official OpenAI-to-Codex default policy in policy.ts and openai-codex-routing.ts to Josh Avant's recent merged work. (role: introduced adjacent policy behavior; confidence: high; commits: 51f4a5e8a040; files: src/agents/harness/policy.ts, src/agents/openai-codex-routing.ts)

Remaining risk / open question:

  • The PR body reports focused unit coverage and a changed gate, but not a live packaged /v1/chat/completions proof for the reporter's exact image path.
  • The linked report listed readiness and HTTP error semantics as possible acceptable outcomes, so maintainers still need to accept fallback-to-PI as the intended policy.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 46a67d30afa3.

@steipete steipete force-pushed the fix/codex-harness-pi-fallback branch from 8a994de to b22f36a Compare May 16, 2026 10:37
@steipete steipete added the proof: override Maintainer override for the external PR real behavior proof gate. label May 16, 2026
@steipete steipete merged commit 225e48f into main May 16, 2026
121 of 127 checks passed
@steipete steipete deleted the fix/codex-harness-pi-fallback branch May 16, 2026 10:42
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 20, 2026
…law#82532)

* fix(agents): fall back to pi when codex harness is unavailable

* fix(agents): align codex fallback auth routing
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
…law#82532)

* fix(agents): fall back to pi when codex harness is unavailable

* fix(agents): align codex fallback auth routing
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
…law#82532)

* fix(agents): fall back to pi when codex harness is unavailable

* fix(agents): align codex fallback auth routing
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 24, 2026
…law#82532)

* fix(agents): fall back to pi when codex harness is unavailable

* fix(agents): align codex fallback auth routing
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
…law#82532)

* fix(agents): fall back to pi when codex harness is unavailable

* fix(agents): align codex fallback auth routing
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 25, 2026
…law#82532)

* fix(agents): fall back to pi when codex harness is unavailable

* fix(agents): align codex fallback auth routing
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
…law#82532)

* fix(agents): fall back to pi when codex harness is unavailable

* fix(agents): align codex fallback auth routing
SebTardif pushed a commit to SebTardif/openclaw that referenced this pull request May 26, 2026
…law#82532)

* fix(agents): fall back to pi when codex harness is unavailable

* fix(agents): align codex fallback auth routing
qiaokuan1992 pushed a commit to qiaokuan1992/openclaw that referenced this pull request Jun 2, 2026
…law#82532)

* fix(agents): fall back to pi when codex harness is unavailable

* fix(agents): align codex fallback auth routing
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
…law#82532)

* fix(agents): fall back to pi when codex harness is unavailable

* fix(agents): align codex fallback auth routing
SYU8384 pushed a commit to SYU8384/openclaw that referenced this pull request Jun 3, 2026
…law#82532)

* fix(agents): fall back to pi when codex harness is unavailable

* fix(agents): align codex fallback auth routing
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
…law#82532)

* fix(agents): fall back to pi when codex harness is unavailable

* fix(agents): align codex fallback auth routing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR proof: override Maintainer override for the external PR real behavior proof gate. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v2026.5.12 regression: /v1/chat/completions returns 500 after selecting unregistered codex harness

1 participant