feat(inference): flip openai/codex + custom cloud slugs to crate-native OpenAiModel#4782
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 44 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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughChangesThe PR adds crate-native BYOK cloud-slug routing, shared slug resolution, Codex Responses API configuration, routing tests, ledger updates, and a tinyagents vendor pointer update. BYOK cloud-slug crate-native cutover
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Caller
participant Factory
participant CloudSlugResolution
participant CrateOpenAI
Caller->>Factory: create_chat_model_with_model_id
Factory->>CloudSlugResolution: resolve slug, model, key, and Codex route
CloudSlugResolution-->>Factory: CloudSlugResolution
Factory->>CrateOpenAI: build crate-native ChatModel
CrateOpenAI-->>Caller: configured ChatModel
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 76ee074ac5
ℹ️ 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".
| endpoint: endpoint.as_str(), | ||
| api_key: key.as_str(), | ||
| auth_style: auth, | ||
| model: effective_model.as_str(), |
There was a problem hiding this comment.
Remap Codex auto before crate Responses calls
When the openai slug resolves to Codex OAuth and the selected/default model is auto, this passes auto straight into the crate OpenAiModel. The legacy Responses path explicitly remaps that sentinel in compatible_helpers.rs (pinned by codex_oauth_responses_remaps_auto_model) because the ChatGPT Codex backend rejects auto; the crate Responses translator sends the model unchanged. As a result, OpenAI OAuth/Codex users configured as openai:auto now get a backend 400 instead of the previous successful concrete Codex-model request.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/openhuman/inference/provider/crate_openai.rs (1)
134-145: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd request-level coverage for the new transport options.
Current tests would still pass if query parameters,
User-Agent, or Responses-mode flags stopped being applied. Add a mocked request test covering Codex Responses routing and non-Codex Chat Completions behavior.🤖 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/crate_openai.rs` around lines 134 - 145, The existing tests do not verify that transport options are applied to outgoing requests. Add mocked request coverage for the provider configuration path around extra query parameters, user-agent, responses_api_primary, and responses_omit_max_output_tokens, asserting Codex requests use Responses routing while non-Codex requests use Chat Completions and preserve the configured query/header behavior.src/openhuman/inference/provider/factory.rs (1)
2238-2380: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing unit coverage for the Codex OAuth branch.
This is the most complex new logic in the cutover (Responses API primary, account/originator headers, user-agent,
client_versionquery param,max_output_tokensomission), yet none of the added tests infactory_tests.rsexercisecodex.using_oauth == true. The existing OpenAI test (try_create_cloud_slug_flips_openai_but_declines_non_cloud) only covers the non-OAuth bearer key path.Consider adding a test that stubs OAuth credentials (matching the bearer key) for the
openaislug and asserts the built model's profile/headers reflect the Responses-primary configuration.🤖 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/factory.rs` around lines 2238 - 2380, Add unit coverage in factory_tests.rs for try_create_cloud_slug_chat_model when the openai slug resolves to Codex OAuth credentials matching the bearer key. Stub the OAuth configuration and assert the resulting model uses Responses API primary behavior, includes the Codex account and originator headers, user-agent, and client_version query parameter, and omits max_output_tokens; retain the existing non-OAuth bearer test separately.
🤖 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/crate_openai.rs`:
- Around line 134-145: The existing tests do not verify that transport options
are applied to outgoing requests. Add mocked request coverage for the provider
configuration path around extra query parameters, user-agent,
responses_api_primary, and responses_omit_max_output_tokens, asserting Codex
requests use Responses routing while non-Codex requests use Chat Completions and
preserve the configured query/header behavior.
In `@src/openhuman/inference/provider/factory.rs`:
- Around line 2238-2380: Add unit coverage in factory_tests.rs for
try_create_cloud_slug_chat_model when the openai slug resolves to Codex OAuth
credentials matching the bearer key. Stub the OAuth configuration and assert the
resulting model uses Responses API primary behavior, includes the Codex account
and originator headers, user-agent, and client_version query parameter, and
omits max_output_tokens; retain the existing non-OAuth bearer test separately.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 05c63283-dbc7-4b38-85f4-bc85d3d70d23
📒 Files selected for processing (5)
docs/tinyagents-drift-ledger.mdsrc/openhuman/inference/provider/crate_openai.rssrc/openhuman/inference/provider/factory.rssrc/openhuman/inference/provider/factory_tests.rsvendor/tinyagents
…ative Extends the BYOK cloud cutover to cover EVERY configured cloud slug except the managed OpenhumanJwt entry. try_create_cloud_slug_chat_model now: - Codex OAuth (Bearer + using_oauth) -> crate OpenAiModel on the Responses API (with_responses_api_primary), with the codex account/originator headers, user-agent, client_version query param, and max_output_tokens omitted. - non-codex openai + custom slugs -> crate OpenAiModel Chat Completions. The legacy host's rare chat-404 -> /v1/responses fallback is NOT replicated (the crate has responses-primary, not fallback); chat completions is these slugs' primary path. Enabled by the crate /v1/responses port (tinyagents#51); host pinned at 8e57665 (= tinyhumansai#49 toggles + tinyhumansai#51 Responses, with tinyhumansai#50 error-source-chain reverted via tinyhumansai#52 so an offline local provider stays retryable). CrateOpenAiConfig / build_crate_openai_model gain responses_api_primary / responses_omit_max_output_tokens / extra_query_params / user_agent knobs. create_chat_model no longer constructs a host OpenAiCompatibleProvider for any managed/local/cloud role; the remaining users of compatible*.rs are the direct create_chat_provider callers (follow-up). Lib compiles clean. LIVE per-provider validation (real openai /responses + codex OAuth + each cloud wire) is deferred to a dedicated tinyagents run. Claude-Session: https://claude.ai/code/session_01U8NDGbt9tKj443VquzycLB
76ee074 to
380107e
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 380107ed4c
ℹ️ 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".
| auth_style: auth, | ||
| model: effective_model.as_str(), | ||
| temperature_unsupported_models: unsupported.as_slice(), | ||
| temperature_override, |
There was a problem hiding this comment.
Preserve the factory temperature for crate cloud models
When this helper now returns a crate OpenAiModel for the newly flipped openai and custom cloud slugs, it only forwards the @<temp> suffix as temperature_override; the temperature argument passed to create_chat_model(..., temperature) never reaches this path. Callers such as meeting summaries (create_chat_model(SUMMARIZATION_ROLE, ..., 0.3)) and automation decisions (..., 0.0) invoke ModelRequest::new(...) without with_temperature, so those OpenAI/custom BYOK requests now go out with the crate default/omitted temperature instead of the deterministic value that ProviderModel previously pinned.
Useful? React with 👍 / 👎.
What & why
Extends the BYOK cloud cutover (#4780) to cover every configured cloud slug
except the managed
OpenhumanJwtentry, socreate_chat_modelno longer buildsa host
OpenAiCompatibleProviderfor any managed / local / cloud role.try_create_cloud_slug_chat_modelnow returns a crate-nativeOpenAiModelfor:Bearer+using_oauth) → OpenAI Responses API(
with_responses_api_primary), carrying the codexaccount_id/originatorheaders, the codex user-agent, theclient_versionquery param,and omitting
max_output_tokens(parity with the legacy host codex path).OpenAiModelon ChatCompletions.
The legacy host's rare chat-
404→/v1/responsesfallback is intentionallynot replicated: the crate models Responses as a primary mode, and Chat
Completions is these slugs' primary path.
Enabled by
/v1/responsesport onOpenAiModel(Responses request/response translation, single-item stream fallback,
max_output_tokens400retry) plus the
responses_api_primary/responses_omit_max_output_tokens/extra_query_params/user_agentbuilder knobs.8e57665= feat(cli): integrate clap_complete for shell command completions #49 (toggles) + Add standalone core autocomplete with Gemma inline completion #51 (Responses), withfeat: split screen intelligence from accessibility and add dedicated settings #50 (error-source-chain) reverted via Feat/refactor UI code #52 so an offline local provider
stays retryable (keeps upstream's loopback test green).
Host
CrateOpenAiConfig/build_crate_openai_modelgain the matching knobs.Testing
cargo check --libclean (pre-existing warnings only).factory_tests:try_create_cloud_slug_flips_openai_but_declines_non_cloud(openai flips →
Some,provider == "openai",model_id == "gpt-4o-mini";managed / local / unconfigured still decline).
/responses, codex OAuth,each cloud endpoint) is deferred to a dedicated tinyagents run with live API
keys, per the migration plan.
Follow-up
The only remaining users of host
compatible*.rsare the directcreate_chat_providercallers; migrating those and deletingcompatible*.rsisthe next step.
Stacked on #4780.
https://claude.ai/code/session_01U8NDGbt9tKj443VquzycLB
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation