Skip to content

Normalize max reasoning effort for Codex routing - #1744

Merged
diegosouzapw merged 2 commits into
cheaper-inference:release/v3.7.4from
duncanleung:codex/normalize-max-effort-codex
Apr 28, 2026
Merged

diegosouzapw merged 2 commits into
cheaper-inference:release/v3.7.4from
duncanleung:codex/normalize-max-effort-codex

Conversation

@duncanleung

Copy link
Copy Markdown
Contributor

Summary

  • normalize top-tier reasoning effort from max to xhigh across Codex-facing translation paths
  • fix OpenAI Chat -> Responses and Claude -> OpenAI bridges so Claude Code fallback traffic no longer sends an unsupported effort value upstream
  • add regression coverage for Codex executor and translator paths

Why

Claude Code can emit or imply top-tier effort as max. Codex now expects xhigh, so max leaks cause 400 errors like:
Invalid value: 'max'. Supported values are: 'none', 'minimal', 'low', 'medium', 'high', and 'xhigh'.

Testing

  • npx --yes tsx --test tests/unit/translator-openai-responses-req.test.ts
  • live local verification against OmniRoute with POST /v1/chat/completions using reasoning_effort: "max" after patching the running install

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request standardizes the "max" reasoning effort tier by mapping it to "xhigh" across the Codex executor, Claude-to-OpenAI translator, and OpenAI Responses translator. It also updates the thinking budget logic and includes comprehensive unit tests for these changes. The reviewer suggested adding string trimming during normalization in the translators to ensure consistency with the Codex implementation and improve robustness against whitespace in client input.

Comment on lines +8 to +13
function normalizeOpenAIReasoningEffort(effort: unknown): string | undefined {
if (typeof effort !== "string") return undefined;
const normalized = effort.toLowerCase();
if (normalized === "max") return "xhigh";
return normalized || undefined;
}

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.

medium

For robustness and consistency with the implementation in open-sse/executors/codex.ts, it is recommended to include .trim() when normalizing the effort string. This ensures that any leading or trailing whitespace provided by the client doesn't bypass the normalization logic.

Suggested change
function normalizeOpenAIReasoningEffort(effort: unknown): string | undefined {
if (typeof effort !== "string") return undefined;
const normalized = effort.toLowerCase();
if (normalized === "max") return "xhigh";
return normalized || undefined;
}
function normalizeOpenAIReasoningEffort(effort: unknown): string | undefined {
if (typeof effort !== "string") return undefined;
const normalized = effort.trim().toLowerCase();
if (normalized === "max") return "xhigh";
return normalized || undefined;
}

Comment on lines +27 to +30
function normalizeResponsesReasoningEffort(value: unknown): string {
const effort = toString(value).toLowerCase();
return effort === "max" ? "xhigh" : effort;
}

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.

medium

To ensure consistency across the codebase and improve robustness against client input variations, consider adding .trim() to the normalization logic here as well. This aligns with the behavior in open-sse/executors/codex.ts.

Suggested change
function normalizeResponsesReasoningEffort(value: unknown): string {
const effort = toString(value).toLowerCase();
return effort === "max" ? "xhigh" : effort;
}
function normalizeResponsesReasoningEffort(value: unknown): string {
const effort = toString(value).trim().toLowerCase();
return effort === "max" ? "xhigh" : effort;
}

@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.7.4 April 28, 2026 23:00
@diegosouzapw
diegosouzapw merged commit d98ca5a into cheaper-inference:release/v3.7.4 Apr 28, 2026
2 checks passed
@diegosouzapw

Copy link
Copy Markdown
Collaborator

Thanks for this great contribution! 🎉 It's now officially merged into the release/v3.7.4 branch and will be part of the next release. We appreciate your effort!

@diegosouzapw diegosouzapw mentioned this pull request Apr 28, 2026
diegosouzapw added a commit that referenced this pull request Apr 28, 2026
* chore(release): v3.7.4 — version bump, openapi and changelog sync

* fix: preserve previous_response_id and conversation_id fields on empty input array (#1729)

* fix: bypass UI validation block for optional API keys and fix string fallback typing (#1721)

* fix(proxy): disable HTTP keep-alive and pipelining in Undici proxy dispatcher to prevent socket hang up

* feat(proxy): implement bulk proxy import via pipe-delimited parser with update-or-create logic

* docs: update changelog for v3.7.4 fixes and proxy features

* test: update responses store expectations for empty input arrays

* feat(pwa): add fullscreen installable PWA with manifest, service worker, and cross-platform app icons. (#1728)

Integrated into release/v3.7.4

* Fix image provider validation and Stability image requests (#1726)

Integrated into release/v3.7.4

* docs: add PR 1726 and PR 1728 to v3.7.4 changelog

* fix(security): replace insecure Math.random with crypto.getRandomValues for fallback UUID generation

* fix(migrations): intercept 007 migration to use IF NOT EXISTS logic on fresh installs

Fixes #1733

* test: fix typescript compilation errors in unit tests

* fix(db): reconcile legacy reasoning cache migration

* chore(release): bump to v3.7.4 — changelog, docs, version sync

* fix(cc-compatible): preserve Claude Code system skeleton (#1740)

Integrated into release/v3.7.4

* docs(changelog): update for PR #1740 merge

* docs(changelog): include workflow updates

* fix(db): reconcile legacy reasoning cache migration (#1734)

Integrated into release/v3.7.4

* Add endpoint tunnel visibility settings (#1743)

Integrated into release/v3.7.4

* Normalize max reasoning effort for Codex routing (#1744)

Integrated into release/v3.7.4

* Fix Claude Code gateway config helper (#1745)

Integrated into release/v3.7.4

* Refresh CLI fingerprint provider profiles (#1746)

Integrated into release/v3.7.4

* Integrated into release/v3.7.4 (PR #1742)

* docs(changelog): update for PRs 1742-1746

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
Co-authored-by: Yash Ghule <y.ghule77@gmail.com>
Co-authored-by: backryun <bakryun0718@proton.me>
Co-authored-by: dhaern <manker_lol@hotmail.com>
Co-authored-by: Randi <55005611+rdself@users.noreply.github.com>
Co-authored-by: Duncan L <leungd@gmail.com>
HouMinXi pushed a commit to HouMinXi/OmniRoute that referenced this pull request Aug 2, 2026
* chore(release): v3.7.4 — version bump, openapi and changelog sync

* fix: preserve previous_response_id and conversation_id fields on empty input array (cheaper-inference#1729)

* fix: bypass UI validation block for optional API keys and fix string fallback typing (cheaper-inference#1721)

* fix(proxy): disable HTTP keep-alive and pipelining in Undici proxy dispatcher to prevent socket hang up

* feat(proxy): implement bulk proxy import via pipe-delimited parser with update-or-create logic

* docs: update changelog for v3.7.4 fixes and proxy features

* test: update responses store expectations for empty input arrays

* feat(pwa): add fullscreen installable PWA with manifest, service worker, and cross-platform app icons. (cheaper-inference#1728)

Integrated into release/v3.7.4

* Fix image provider validation and Stability image requests (cheaper-inference#1726)

Integrated into release/v3.7.4

* docs: add PR 1726 and PR 1728 to v3.7.4 changelog

* fix(security): replace insecure Math.random with crypto.getRandomValues for fallback UUID generation

* fix(migrations): intercept 007 migration to use IF NOT EXISTS logic on fresh installs

Fixes cheaper-inference#1733

* test: fix typescript compilation errors in unit tests

* fix(db): reconcile legacy reasoning cache migration

* chore(release): bump to v3.7.4 — changelog, docs, version sync

* fix(cc-compatible): preserve Claude Code system skeleton (cheaper-inference#1740)

Integrated into release/v3.7.4

* docs(changelog): update for PR cheaper-inference#1740 merge

* docs(changelog): include workflow updates

* fix(db): reconcile legacy reasoning cache migration (cheaper-inference#1734)

Integrated into release/v3.7.4

* Add endpoint tunnel visibility settings (cheaper-inference#1743)

Integrated into release/v3.7.4

* Normalize max reasoning effort for Codex routing (cheaper-inference#1744)

Integrated into release/v3.7.4

* Fix Claude Code gateway config helper (cheaper-inference#1745)

Integrated into release/v3.7.4

* Refresh CLI fingerprint provider profiles (cheaper-inference#1746)

Integrated into release/v3.7.4

* Integrated into release/v3.7.4 (PR cheaper-inference#1742)

* docs(changelog): update for PRs 1742-1746

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
Co-authored-by: Yash Ghule <y.ghule77@gmail.com>
Co-authored-by: backryun <bakryun0718@proton.me>
Co-authored-by: dhaern <manker_lol@hotmail.com>
Co-authored-by: Randi <55005611+rdself@users.noreply.github.com>
Co-authored-by: Duncan L <leungd@gmail.com>
Poid-ZA pushed a commit to Poid-ZA/OmniRoute that referenced this pull request Aug 5, 2026
* chore(release): v3.7.4 — version bump, openapi and changelog sync

* fix: preserve previous_response_id and conversation_id fields on empty input array (cheaper-inference#1729)

* fix: bypass UI validation block for optional API keys and fix string fallback typing (cheaper-inference#1721)

* fix(proxy): disable HTTP keep-alive and pipelining in Undici proxy dispatcher to prevent socket hang up

* feat(proxy): implement bulk proxy import via pipe-delimited parser with update-or-create logic

* docs: update changelog for v3.7.4 fixes and proxy features

* test: update responses store expectations for empty input arrays

* feat(pwa): add fullscreen installable PWA with manifest, service worker, and cross-platform app icons. (cheaper-inference#1728)

Integrated into release/v3.7.4

* Fix image provider validation and Stability image requests (cheaper-inference#1726)

Integrated into release/v3.7.4

* docs: add PR 1726 and PR 1728 to v3.7.4 changelog

* fix(security): replace insecure Math.random with crypto.getRandomValues for fallback UUID generation

* fix(migrations): intercept 007 migration to use IF NOT EXISTS logic on fresh installs

Fixes cheaper-inference#1733

* test: fix typescript compilation errors in unit tests

* fix(db): reconcile legacy reasoning cache migration

* chore(release): bump to v3.7.4 — changelog, docs, version sync

* fix(cc-compatible): preserve Claude Code system skeleton (cheaper-inference#1740)

Integrated into release/v3.7.4

* docs(changelog): update for PR cheaper-inference#1740 merge

* docs(changelog): include workflow updates

* fix(db): reconcile legacy reasoning cache migration (cheaper-inference#1734)

Integrated into release/v3.7.4

* Add endpoint tunnel visibility settings (cheaper-inference#1743)

Integrated into release/v3.7.4

* Normalize max reasoning effort for Codex routing (cheaper-inference#1744)

Integrated into release/v3.7.4

* Fix Claude Code gateway config helper (cheaper-inference#1745)

Integrated into release/v3.7.4

* Refresh CLI fingerprint provider profiles (cheaper-inference#1746)

Integrated into release/v3.7.4

* Integrated into release/v3.7.4 (PR cheaper-inference#1742)

* docs(changelog): update for PRs 1742-1746

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
Co-authored-by: Yash Ghule <y.ghule77@gmail.com>
Co-authored-by: backryun <bakryun0718@proton.me>
Co-authored-by: dhaern <manker_lol@hotmail.com>
Co-authored-by: Randi <55005611+rdself@users.noreply.github.com>
Co-authored-by: Duncan L <leungd@gmail.com>
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
muhamadgalihsaputra pushed a commit to niyatna/NiyatnaRoute that referenced this pull request Sep 27, 2026
* chore(release): v3.7.4 — version bump, openapi and changelog sync

* fix: preserve previous_response_id and conversation_id fields on empty input array (cheaper-inference#1729)

* fix: bypass UI validation block for optional API keys and fix string fallback typing (cheaper-inference#1721)

* fix(proxy): disable HTTP keep-alive and pipelining in Undici proxy dispatcher to prevent socket hang up

* feat(proxy): implement bulk proxy import via pipe-delimited parser with update-or-create logic

* docs: update changelog for v3.7.4 fixes and proxy features

* test: update responses store expectations for empty input arrays

* feat(pwa): add fullscreen installable PWA with manifest, service worker, and cross-platform app icons. (cheaper-inference#1728)

Integrated into release/v3.7.4

* Fix image provider validation and Stability image requests (cheaper-inference#1726)

Integrated into release/v3.7.4

* docs: add PR 1726 and PR 1728 to v3.7.4 changelog

* fix(security): replace insecure Math.random with crypto.getRandomValues for fallback UUID generation

* fix(migrations): intercept 007 migration to use IF NOT EXISTS logic on fresh installs

Fixes cheaper-inference#1733

* test: fix typescript compilation errors in unit tests

* fix(db): reconcile legacy reasoning cache migration

* chore(release): bump to v3.7.4 — changelog, docs, version sync

* fix(cc-compatible): preserve Claude Code system skeleton (cheaper-inference#1740)

Integrated into release/v3.7.4

* docs(changelog): update for PR cheaper-inference#1740 merge

* docs(changelog): include workflow updates

* fix(db): reconcile legacy reasoning cache migration (cheaper-inference#1734)

Integrated into release/v3.7.4

* Add endpoint tunnel visibility settings (cheaper-inference#1743)

Integrated into release/v3.7.4

* Normalize max reasoning effort for Codex routing (cheaper-inference#1744)

Integrated into release/v3.7.4

* Fix Claude Code gateway config helper (cheaper-inference#1745)

Integrated into release/v3.7.4

* Refresh CLI fingerprint provider profiles (cheaper-inference#1746)

Integrated into release/v3.7.4

* Integrated into release/v3.7.4 (PR cheaper-inference#1742)

* docs(changelog): update for PRs 1742-1746

---------

Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com>
Co-authored-by: Yash Ghule <y.ghule77@gmail.com>
Co-authored-by: backryun <bakryun0718@proton.me>
Co-authored-by: dhaern <manker_lol@hotmail.com>
Co-authored-by: Randi <55005611+rdself@users.noreply.github.com>
Co-authored-by: Duncan L <leungd@gmail.com>
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.

3 participants