Skip to content

Normalize codex-cli helper/embedded Codex resolution to openai-codex - #38215

Closed
huangyongde wants to merge 5 commits into
openclaw:mainfrom
huangyongde:codex/codex-cli-gpt54-helper-compat
Closed

huangyongde wants to merge 5 commits into
openclaw:mainfrom
huangyongde:codex/codex-cli-gpt54-helper-compat

Conversation

@huangyongde

Copy link
Copy Markdown

Summary

This patch fixes an inconsistency where helper / embedded paths still treated codex-cli as a separate provider for Codex model resolution and auth lookup, even though the same Codex-backed models already work through the openai-codex path.

Fixes #38212.

Changes

  1. Extend Codex forward-compat to accept codex-cli for gpt-5.4 and gpt-5.3-codex.
  2. Reuse openai-codex template metadata when codex-cli enters the embedded resolver.
  3. Normalize codex-cli to openai-codex for auth profile lookup.
  4. Add codex-cli/gpt-5.4 and codex-cli/gpt-5.3-codex to xhigh-capable model refs.
  5. Add regression tests for forward-compat, auth lookup, and thinking-level support.

Why

Before this change:

  • openai-codex/gpt-5.4 had forward-compat support
  • codex-cli/gpt-5.4 could still fail in helper / embedded paths
  • auth lookup for codex-cli did not reuse existing openai-codex OAuth credentials

The fix makes codex-cli consistent with the Codex OAuth-backed provider in the internal helper / embedded path, without changing top-level model-ref syntax.

Validation

Ran targeted tests:

pnpm exec vitest run   src/agents/pi-embedded-runner/model.forward-compat.test.ts   src/agents/auth-profiles/order.test.ts   src/auto-reply/thinking.test.ts

Result:

  • 3 test files passed
  • 29 tests passed

Notes

This is intentionally scoped to internal helper / embedded compatibility for Codex-backed refs and does not change the user-facing codex-cli/... configuration syntax.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Mar 6, 2026
@greptile-apps

greptile-apps Bot commented Mar 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR normalizes codex-cli provider references to reuse openai-codex credentials, template metadata, and xhigh-capable model refs in the internal helper/embedded paths. The change is well-scoped and does not alter the user-facing codex-cli/... configuration syntax.

Key Changes:

  • model-forward-compat.ts: Adds codex-cli to the eligible-provider sets for gpt-5.4 and gpt-5.3-codex forward-compat resolution, introduces registryProvider to redirect template registry lookups to openai-codex, and ensures the resulting model's provider field is explicitly set to openai-codex in both the template-found and fallback paths.
  • model-selection.ts: Extends normalizeProviderIdForAuth to map codex-cli → openai-codex, mirroring the existing volcengine-plan → volcengine pattern.
  • thinking.ts: Adds codex-cli/gpt-5.4 and codex-cli/gpt-5.3-codex to XHIGH_MODEL_REFS so that supportsXHighThinking returns true when called with the original (non-normalized) provider name before forward-compat resolution.
  • Test files: Targeted regression coverage for forward-compat resolution, auth profile order lookup, and xhigh thinking-level support.

Confidence Score: 5/5

  • Safe to merge — changes are well-scoped, logically consistent, and fully covered by targeted regression tests.
  • All three modified logic files follow the established volcengine-plan → volcengine normalization pattern. The registryProvider indirection in resolveOpenAICodexForwardCompatModel is correct: it redirects template lookups to openai-codex while ensuring both code paths return provider: "openai-codex". Auth profile lookup correctly delegates to normalizeProviderIdForAuth, which now maps codex-cli → openai-codex, and listProfilesForProvider already uses this function so it automatically picks up openai-codex credentials for codex-cli requests. Thinking-level support is added via direct model-ref entries in XHIGH_MODEL_REFS. Test coverage spans forward-compat resolution, auth profile ordering, and thinking-level support for all new refs.
  • No files require special attention.

Last reviewed commit: 8693611

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

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: 8693611b39

ℹ️ 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 on lines +67 to +68
if (normalized === "codex-cli") {
return "openai-codex";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Honor openai-codex auth order for codex-cli lookups

Mapping codex-cli to openai-codex in normalizeProviderIdForAuth makes resolveAuthProfileOrder pull the same credentials, but explicit ordering is still read via findNormalizedProviderValue(..., providerKey) where providerKey stays codex-cli (see resolveAuthProfileOrder), so auth.order["openai-codex"] is ignored for codex-cli runs. In setups with multiple Codex profiles, this can select a different key than the user-configured priority and cause avoidable auth/rate-limit failures.

Useful? React with 👍 / 👎.

@openclaw-barnacle openclaw-barnacle Bot added the channel: feishu Channel integration: feishu label Mar 6, 2026
@huangyongde
huangyongde force-pushed the codex/codex-cli-gpt54-helper-compat branch from 20f6bcf to 0b01b81 Compare March 7, 2026 03:34

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

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: 0b01b81253

ℹ️ 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".

modelRegistry: ModelRegistry,
): Model<Api> | undefined {
const normalizedProvider = normalizeProviderId(provider);
const registryProvider = normalizedProvider === "codex-cli" ? "openai-codex" : normalizedProvider;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Apply openai-codex overrides to codex-cli forward-compat

Mapping codex-cli to openai-codex here changes the resolved model provider, but resolveModelWithRegistry still fetches provider config from the original request provider (src/agents/pi-embedded-runner/model.ts:109) before applying forward-compat. In practice, codex-cli/gpt-5.4 and codex-cli/gpt-5.3-codex now run as openai-codex without applying models.providers.openai-codex overrides (for example custom baseUrl/headers), so deployments that route Codex traffic through a proxy can silently fall back to the default ChatGPT endpoint.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

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: d070599b45

ℹ️ 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 on lines +67 to +69
if (normalized === "codex-cli") {
return "openai-codex";
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Keep user-pinned codex-cli auth profiles locked

By mapping codex-cli to openai-codex in auth normalization, resolveAuthProfileOrder can now return OpenAI Codex profiles for codex-cli runs, but the lock gate in src/agents/pi-embedded-runner/run.ts still validates user-pinned profiles with normalizeProviderId (exact provider family), so authProfileIdSource: "user" is silently unset for openai-codex:* profiles on codex-cli. In that case an expired/invalid pinned profile no longer hard-fails as a user lock and the runner can rotate to a different profile, which breaks explicit profile selection semantics.

Useful? React with 👍 / 👎.

@Takhoffman
Takhoffman requested a review from a team as a code owner March 24, 2026 20:16
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Apr 21, 2026
@steipete

Copy link
Copy Markdown
Contributor

Closing this as implemented after Codex review.

Current main already subsumes this PR with a broader manifest-backed codex-cli -> openai-codex auth alias path plus Codex harness auth forwarding, including fixes for the auth-order and pinned-profile concerns raised in review.

What I checked:

  • Bundled OpenAI plugin declares codex-cli as the legacy Codex auth choice: The bundled OpenAI plugin marks codex-cli as a deprecated choice id for the openai-codex OAuth path, which is the manifest metadata the new auth-alias system consumes. (extensions/openai/openclaw.plugin.json:12, 017252e4f8e7)
  • Main maps deprecated auth choice ids to canonical provider ids: resolveProviderAuthAliasMap() imports deprecatedChoiceIds from plugin manifests, and resolveProviderIdForAuth() resolves codex-cli to openai-codex; the dedicated test asserts that mapping explicitly. (src/agents/provider-auth-aliases.ts:107, 017252e4f8e7)
  • Auth order now honors the canonical provider first: resolveAuthProfileOrder() now computes providerAuthKey via resolveProviderIdForAuth() and checks canonical auth order before falling back to the legacy provider key, covering the review comment about auth.order[openai-codex] being ignored for codex-cli runs. (src/agents/auth-profiles/order.ts:72, 017252e4f8e7)
  • Pinned-profile locking uses canonical auth provider matching: The embedded runner now validates user-locked profiles with resolveProviderIdForAuth() for both the stored profile and the run provider, so codex-cli and openai-codex stay equivalent for lock semantics. (src/agents/pi-embedded-runner/run.ts:418, 017252e4f8e7)
  • Codex harness auth forwarding is explicit and regression-tested: buildAgentRuntimeAuthPlan() forwards openai-codex auth into Codex harness runs, with regression coverage for forwarded auth profiles in both the runtime-plan and embedded-runner tests. (src/agents/runtime-plan/auth.ts:17, 017252e4f8e7)

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review notes: reviewed against 017252e4f8e7; fix evidence: commit 017252e4f8e7.

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

Labels

agents Agent runtime and tooling channel: feishu Channel integration: feishu size: S stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codex-cli/gpt-5.4 fails in embedded/helper paths while openai-codex/gpt-5.4 works

2 participants