Skip to content

fix(provider): remap Codex auto model#4240

Open
YOMXXX wants to merge 5 commits into
tinyhumansai:mainfrom
YOMXXX:fix/GH-4206-codex-auto-model
Open

fix(provider): remap Codex auto model#4240
YOMXXX wants to merge 5 commits into
tinyhumansai:mainfrom
YOMXXX:fix/GH-4206-codex-auto-model

Conversation

@YOMXXX

@YOMXXX YOMXXX commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Remaps Codex OAuth Responses requests from model=auto to the first known concrete Codex model before posting.
  • Keeps Codex-specific stream: true and max_output_tokens omission behaviour intact.
  • Carries forward two existing Markdown link fixes needed for the repository link checker.

Problem

  • Closes a Sentry-traced OpenAI Codex OAuth failure where auto leaked into chatgpt.com/backend-api/codex/responses.
  • The ChatGPT-account Codex Responses endpoint rejects the Codex CLI auto sentinel with HTTP 400.
  • Existing Codex Responses handling already strips unsupported fields, but did not resolve the model sentinel.

Solution

  • Detect the Codex OAuth Responses endpoint and model=auto in chat_via_responses.
  • Resolve auto to the first OPENAI_CODEX_MODEL_HINTS entry before serializing ResponsesRequest.
  • Add a regression test with an exact JSON body matcher proving the provider never posts auto.
  • Keep the docs link-fix commits on this branch because current upstream/main lacks them and Markdown Link Check fails without them.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • Diff coverage ≥ 80% — changed lines (Vitest + cargo-llvm-cov merged via diff-cover) meet the gate enforced by .github/workflows/pr-ci.yml. Run pnpm test:coverage and pnpm test:rust locally; PRs below 80% on changed lines will not merge. Covered by targeted Rust regression and CI diff coverage.
  • N/A: Coverage matrix updated — provider request-shape bugfix, no feature row added/removed/renamed.
  • N/A: All affected feature IDs from the matrix are listed in the PR description under ## Related — no matrix feature IDs changed.
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • N/A: Manual smoke checklist updated if this touches release-cut surfaces — provider bugfix only, covered by mock-backed Rust tests.
  • Linked issue closed via Closes #NNN in the ## Related section

Impact

  • Runtime impact is limited to OpenAI ChatGPT-account Codex OAuth Responses requests.
  • Prevents a provider-owned 400 loop for users whose config carries the Codex CLI auto model alias.
  • No migration, storage, or UI impact.

Related


AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: fix/GH-4206-codex-auto-model
  • Commit SHA: b49d868d356f559a7edafec51e2dfb294a6cac45

Validation Run

  • N/A: pnpm --filter openhuman-app format:check — no frontend changes.
  • N/A: pnpm typecheck — no TypeScript changes.
  • Focused tests:
    • GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml --lib codex_responses_remaps_auto_model_before_posting (RED before fix, GREEN after fix)
    • GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml --lib codex_responses
    • GGML_NATIVE=OFF cargo test --manifest-path Cargo.toml --lib responses_api_primary_posts_directly_to_responses
  • Rust fmt/check (if changed):
    • cargo fmt --manifest-path Cargo.toml --check
    • git diff --check
    • GGML_NATIVE=OFF cargo check --manifest-path Cargo.toml
  • N/A: Tauri fmt/check — no Tauri crate changes.

Validation Blocked

  • command: N/A
  • error: N/A
  • impact: N/A

Behavior Changes

  • Intended behavior change: Codex OAuth Responses calls now send a concrete Codex model instead of the auto sentinel.
  • User-visible effect: Codex-backed OpenAI Responses chat stops failing with The 'auto' model is not supported when using Codex with a ChatGPT account.

Parity Contract

  • Legacy behavior preserved: Non-Codex Responses endpoints still receive their caller-provided model unchanged.
  • Guard/fallback/dispatch parity checks: Existing Codex stream: true and max_output_tokens omission tests still pass.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): N/A
  • Canonical PR: this PR
  • Resolution (closed/superseded/updated): N/A

Summary by CodeRabbit

  • Bug Fixes
    • Improved Codex response handling so when automatic model selection is requested, a supported model is sent instead of auto.
    • Error/telemetry reporting now uses the remapped model value actually sent to the service.
  • Tests
    • Added async integration tests covering Codex response “auto” remapping, including correct SSE aggregation and error reporting.
  • Documentation
    • Updated localized README social link formatting for Reddit.
    • Corrected native voice documentation links and refreshed the Cursor Cloud Agents URL.
    • Updated Star History chart embed URLs to the current API endpoints.

@YOMXXX YOMXXX requested a review from a team June 28, 2026 16:56
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Remaps Codex Responses model=auto to a concrete model before posting, and updates localized documentation links and embeds across multiple README files plus one workflow doc.

Changes

Codex OAuth auto-model remap

Layer / File(s) Summary
auto model remap
src/openhuman/inference/provider/compatible_helpers.rs
Imports OPENAI_CODEX_MODEL_HINTS, resolves auto to the first hint with a gpt-5.5 fallback, and uses the resolved value for the outbound ResponsesRequest.model and later logging.
Integration test for auto remapping
src/openhuman/inference/provider/compatible_tests.rs
Adds WireMock-based async tests that assert auto is rewritten before posting to /backend-api/codex/responses, the SSE response is aggregated, and the emitted Sentry event uses the resolved model tag on error.

README and docs link corrections

Layer / File(s) Summary
README link corrections across locales
docs/README.de.md, docs/README.ja-JP.md, docs/README.ko.md, docs/README.ur-pk.md, docs/README.zh-CN.md
Reddit entries become plain text, native voice links move to features/native-tools/voice, and Star History embeds switch to api.star-history.com.
Cursor Cloud Agents link update
docs/agent-workflows/cursor-cloud-agents.md
The Cursor Cloud Agents documentation link changes to a new URL.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

rust-core, bug

Poem

🐇 “auto” hopped in, then found its cue,
A concrete model came shining through.
Links got a polish, stars took a spin,
The burrow feels neat from shell to skin.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Several README and agent-doc link edits are unrelated to the Codex model remap issue. Move the documentation/link cleanup to a separate PR or link the related issue if it is intended to ship here.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main provider fix: remapping Codex auto model.
Linked Issues check ✅ Passed The code remaps model=auto to a concrete Codex model before POSTing, and the new tests verify it.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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 added bug rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure. labels Jun 28, 2026

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

🧹 Nitpick comments (1)
src/openhuman/inference/provider/compatible_tests.rs (1)

1073-1081: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Derive the expected model from OPENAI_CODEX_MODEL_HINTS.

This regression is meant to verify “auto becomes the first concrete Codex model,” but the matcher hardcodes the current first entry. If OPENAI_CODEX_MODEL_HINTS changes order later, the implementation will stay correct and this test will fail for the wrong reason. Build the expected "model" field from the same constant the helper uses.

🤖 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/openhuman/inference/provider/compatible_tests.rs` around lines 1073 -
1081, The test expectation is hardcoded to a specific model value, which makes
it brittle if OPENAI_CODEX_MODEL_HINTS changes order. Update the compatible test
around the body_json assertion to derive the expected "model" from the same
OPENAI_CODEX_MODEL_HINTS constant used by the helper, so the regression
continues to verify that auto resolves to the first concrete Codex model without
depending on a fixed entry.
🤖 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/openhuman/inference/provider/compatible_tests.rs`:
- Around line 1073-1081: The test expectation is hardcoded to a specific model
value, which makes it brittle if OPENAI_CODEX_MODEL_HINTS changes order. Update
the compatible test around the body_json assertion to derive the expected
"model" from the same OPENAI_CODEX_MODEL_HINTS constant used by the helper, so
the regression continues to verify that auto resolves to the first concrete
Codex model without depending on a fixed entry.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d1762a3e-cb4d-4c01-91bb-33400e15d6f3

📥 Commits

Reviewing files that changed from the base of the PR and between 5a41a4f and 14b8a43.

📒 Files selected for processing (8)
  • docs/README.de.md
  • docs/README.ja-JP.md
  • docs/README.ko.md
  • docs/README.ur-pk.md
  • docs/README.zh-CN.md
  • docs/agent-workflows/cursor-cloud-agents.md
  • src/openhuman/inference/provider/compatible_helpers.rs
  • src/openhuman/inference/provider/compatible_tests.rs

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/openhuman/inference/provider/compatible_helpers.rs`:
- Around line 176-177: The Responses error/reporting paths in
compatible_helpers.rs are still using the original model value instead of the
remapped request_model, which makes telemetry and structured error fields
inconsistent after auto is rewritten. Update the helper branches that build
error/status/reporting payloads to thread request_model through every path,
including the final structured ("model", ...) field, so Codex OAuth and related
failures are attributed to the concrete wire model actually sent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f7660400-009c-4d15-9811-aad507dfad8d

📥 Commits

Reviewing files that changed from the base of the PR and between 14b8a43 and dc671e2.

📒 Files selected for processing (1)
  • src/openhuman/inference/provider/compatible_helpers.rs

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@src/openhuman/inference/provider/compatible_helpers.rs`:
- Around line 176-177: The Responses error/reporting paths in
compatible_helpers.rs are still using the original model value instead of the
remapped request_model, which makes telemetry and structured error fields
inconsistent after auto is rewritten. Update the helper branches that build
error/status/reporting payloads to thread request_model through every path,
including the final structured ("model", ...) field, so Codex OAuth and related
failures are attributed to the concrete wire model actually sent.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f7660400-009c-4d15-9811-aad507dfad8d

📥 Commits

Reviewing files that changed from the base of the PR and between 14b8a43 and dc671e2.

📒 Files selected for processing (1)
  • src/openhuman/inference/provider/compatible_helpers.rs
🛑 Comments failed to post (1)
src/openhuman/inference/provider/compatible_helpers.rs (1)

176-177: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use the remapped model in every Responses error/reporting path.

After Lines 60-73 rewrite auto to request_model, this block still reports model, so Codex OAuth failures are attributed to "auto" even though the wire request was sent with a concrete model. That leaves the new telemetry contract inconsistent with the actual request body. Thread request_model through all of these helpers and the final structured ("model", …) field.

Suggested fix
         if super::super::is_budget_exhausted_http_400(status, &error) {
             super::super::log_budget_exhausted_http_400(
                 "responses_api",
                 self.name.as_str(),
-                Some(model),
+                Some(request_model),
                 status,
             );
         } else if super::super::is_custom_openai_upstream_bad_request_http_400(
             self.name.as_str(),
             status,
@@
             super::super::log_custom_openai_upstream_bad_request_http_400(
                 "responses_api",
                 self.name.as_str(),
-                Some(model),
+                Some(request_model),
                 status,
             );
         } else if super::super::is_provider_access_policy_denied_http_403(status, &error) {
             super::super::log_provider_access_policy_denied_http_403(
                 "responses_api",
                 self.name.as_str(),
-                Some(model),
+                Some(request_model),
                 status,
             );
         } else if super::super::is_provider_config_rejection_http(
             status,
             self.name.as_str(),
@@
             super::super::log_provider_config_rejection(
                 "responses_api",
                 self.name.as_str(),
-                Some(model),
+                Some(request_model),
                 status,
             );
         } else if super::super::is_byo_provider_auth_failure_http(
             self.name.as_str(),
             status,
@@
             super::super::log_byo_provider_auth_failure(
                 "responses_api",
                 self.name.as_str(),
-                Some(model),
+                Some(request_model),
                 status,
             );
         } else if super::super::is_openai_oauth_session_expired_http(
             self.name.as_str(),
             status,
@@
             super::super::log_openai_oauth_session_expired(
                 "responses_api",
                 self.name.as_str(),
-                Some(model),
+                Some(request_model),
                 status,
             );
         } else if super::super::is_provider_insufficient_credits_402(status, &error) {
@@
             super::super::log_provider_insufficient_credits_402(
                 "responses_api",
                 self.name.as_str(),
-                Some(model),
+                Some(request_model),
                 status,
             );
         } else if super::super::should_report_provider_http_failure(status) {
@@
                 &[
                     ("provider", self.name.as_str()),
-                    ("model", model),
+                    ("model", request_model),
                     ("status", status_str.as_str()),
                     ("failure", "non_2xx"),
                 ],
             );
         }

Also applies to: 187-195, 205-206, 216-217, 227-228, 241-242, 251-251

🤖 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/openhuman/inference/provider/compatible_helpers.rs` around lines 176 -
177, The Responses error/reporting paths in compatible_helpers.rs are still
using the original model value instead of the remapped request_model, which
makes telemetry and structured error fields inconsistent after auto is
rewritten. Update the helper branches that build error/status/reporting payloads
to thread request_model through every path, including the final structured
("model", ...) field, so Codex OAuth and related failures are attributed to the
concrete wire model actually sent.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/openhuman/inference/provider/compatible_tests.rs (1)

1069-1108: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Split these Codex remap tests into a dedicated test module.

compatible_tests.rs is already >1,100 lines, so adding more cases here deepens an existing module-size violation and makes this provider test matrix harder to navigate. Please move the new Codex Responses remap coverage into a focused sibling test file/submodule instead of extending this file further. As per coding guidelines, Rust modules must be ≤ ~500 lines in size.

Also applies to: 1110-1158

🤖 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/openhuman/inference/provider/compatible_tests.rs` around lines 1069 -
1108, The new Codex remap coverage should not stay in compatible_tests.rs
because that module is already too large; move the added tests, including
codex_responses_remaps_auto_model_before_posting and the related Codex remap
cases, into a dedicated sibling test module/file for the
OpenAiCompatibleProvider provider tests. Keep the existing assertions and setup
intact, but relocate the test helpers and imports so the provider test matrix
stays organized and the module size remains within the guideline.

Source: Coding guidelines

🤖 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.

Outside diff comments:
In `@src/openhuman/inference/provider/compatible_tests.rs`:
- Around line 1069-1108: The new Codex remap coverage should not stay in
compatible_tests.rs because that module is already too large; move the added
tests, including codex_responses_remaps_auto_model_before_posting and the
related Codex remap cases, into a dedicated sibling test module/file for the
OpenAiCompatibleProvider provider tests. Keep the existing assertions and setup
intact, but relocate the test helpers and imports so the provider test matrix
stays organized and the module size remains within the guideline.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ed105a34-1031-4afb-a55b-57ad9f0d23eb

📥 Commits

Reviewing files that changed from the base of the PR and between dc671e2 and b49d868.

📒 Files selected for processing (2)
  • src/openhuman/inference/provider/compatible_helpers.rs
  • src/openhuman/inference/provider/compatible_tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/openhuman/inference/provider/compatible_helpers.rs

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

Labels

bug rust-core Core Rust runtime in src/: CLI, core_server, shared infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

openai Codex Responses: remap model='auto' to a concrete model (TAURI-RUST-AHX)

1 participant