Skip to content

fix(openai): accept OpenAI's off-ish reasoning_effort values - #433

Closed
sypsyp97 wants to merge 1 commit into
youssofal:mainfrom
sypsyp97:openai-effort-aliases
Closed

sypsyp97 wants to merge 1 commit into
youssofal:mainfrom
sypsyp97:openai-effort-aliases

Conversation

@sypsyp97

@sypsyp97 sypsyp97 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

A client that hardcodes OpenAI's reasoning_effort: "minimal" or "none" gets a 400 out of the chat request path. Cherry Studio's translate pane sends one on every call and exposes no effort picker, so the entire pane is unusable against MTPLX — reproduced against 2.11.0:

$ curl -s localhost:8080/v1/chat/completions -H 'Content-Type: application/json' \
    -d '{"model":"...","messages":[{"role":"user","content":"hi"}],"reasoning_effort":"none"}'
{"message": "reasoning_effort must be one of: auto, low, medium, high, xhigh",
 "type": "invalid_request_error", ...}

This maps minimal/none/off/disable/disabled onto the lowest level in normalize_reasoning_effort, the one place the request path and the live-settings POST share.

None of those values can mean "no reasoning" on this server — that is reasoning: off or chat_template_kwargs.enable_thinking — and reasoning_effort can only answer with a level, so the lowest one is the closest available answer rather than a rejected request. Deliberately not wired to reasoning-off, because a client asking for an effort level should not have thinking silently disabled underneath it.

Scope is narrow by construction:

  • REASONING_EFFORT_CHOICES is untouched, so every family's effort_levels contract and the app's picker are unchanged.
  • Junk values still raise ("banana" → 400).
  • The aliases only widen what arrives over the wire: --reasoning-effort is gated by argparse choices=REASONING_EFFORT_CHOICES and mtplx config set compares against the same tuple, so an alias cannot reach either surface.

I left CHANGELOG.md alone since entries there look maintainer-written at release time; happy to add one in whatever wording you prefer.

Verification

macOS 15.6 (arm64), Python 3.12.13, this branch installed with -e ".[dev,server]".

python -m pytest tests/test_no_mlx_imports.py tests/test_public_cli.py \
                 tests/test_runtime_kpis.py tests/test_qwen38_family.py \
                 tests/test_openai_bridge.py
453 passed

python -m build              -> mtplx-2.10.2-py3-none-any.whl
scripts/fresh_venv_smoke.sh  -> passed no-MLX CLI survival checks
scripts/check_ai_attribution.py --range upstream/main..HEAD -> clean

New test test_normalize_reasoning_effort_maps_openai_off_values covers the five aliases plus case and whitespace variants, asserts every canonical choice still round-trips, and asserts junk still raises.

End to end on a live server (Qwen3.8-27B-UD-Q4_K_XL, one M5 Pro, --profile turbo --reasoning on --reasoning-effort xhigh): minimal, none, off, disable all return 200 after the change and banana still returns 400.

Benchmark Evidence

No runtime performance change: the added lookup is one dict get on the request-validation path, before generation.

Clients that hardcode OpenAI's "minimal" or "none" got a 400 from the chat
request path, which validates through the same normalizer as the
live-settings POST. Cherry Studio's translate pane sends one on every call
and exposes no effort picker, so the whole pane was unusable against a
server whose vocabulary starts at "low".

Map minimal/none/off/disable/disabled onto the lowest level. None of them
can mean "no reasoning" here -- that is `reasoning: off` or
chat_template_kwargs.enable_thinking -- and reasoning_effort can only answer
with a level, so the lowest one is the closest available answer.

The canonical vocabulary is unchanged and junk values still raise. The
aliases only widen what arrives over the wire: argparse gates
--reasoning-effort on REASONING_EFFORT_CHOICES and `mtplx config set`
compares against the same tuple, so an alias never reaches either.
@sypsyp97
sypsyp97 requested a review from youssofal as a code owner September 2, 2026 07:24
Copilot AI lite review requested due to automatic review settings September 2, 2026 07:24

Copilot AI 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.

🟢 Approval recommended

The change is narrowly scoped, preserves the canonical vocabulary/contracts, and is covered by a targeted regression test for the new alias behavior.

Pull request overview

This PR updates MTPLX’s shared reasoning_effort normalizer to accept several OpenAI client “off-ish” reasoning_effort values (e.g., none, minimal) by mapping them to the lowest supported effort level instead of returning a 400, improving compatibility with clients that hardcode these values.

Changes:

  • Add an alias map in normalize_reasoning_effort to coerce minimal/none/off/disable/disabled to the lowest effort level.
  • Add a regression test covering alias mapping (including case/whitespace variants) while preserving existing behavior for canonical values and junk inputs.
File summaries
File Description
tests/test_qwen38_family.py Adds a new test ensuring OpenAI “off-ish” reasoning_effort values normalize to the lowest supported level and invalid values still raise.
mtplx/reasoning_effort.py Introduces _OPENAI_EFFORT_ALIASES and applies it during normalization without changing the canonical REASONING_EFFORT_CHOICES vocabulary.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

youssofal pushed a commit that referenced this pull request Sep 4, 2026
…from PR #433 by sypsyp97

minimal / none / off / disable / disabled map onto the lowest reasoning level in normalize_reasoning_effort, the
one place the request path and the live-settings POST share. Clients that hardcode OpenAI's values (Cherry Studio's
translate pane sends one on every call with no effort picker) stop receiving 400s. Junk values still raise; the
canonical vocabulary, the CLI argparse choices and mtplx config set are unchanged. Deliberately not wired to
reasoning-off: an effort level request must not silently disable thinking.

Technique credit: sypsyp97 (PR #433)
Verification here: tests/test_qwen38_family.py, tests/test_openai_bridge.py, tests/test_public_cli.py pass on the port
branch (outputs/pr433-port-tests.log, rc 0).
youssofal added a commit that referenced this pull request Sep 4, 2026
Flash-Next speed lane on by default (PR #391 restack by davidtai, ported with
his authorship), K2 flash-decoding verify route on in turbo for the 27B,
copy-lane streaming fixed at the engine (server release pacer) and app
(typewriter pacer) layers, per-request memory gate for the fixed-M4 lane,
Route Tape fixes, fixes for #441 (Anthropic image blocks), #427 (--allow-swap),
#420 (ar_batch cache-family guard), #436 (client cap diagnostics), #433 port
(sypsyp97), #423 opt-in Steel sparse-GQA prefill (Thanh Pham), light appearance
for the app (#428), the app in twelve languages, and the 2.11.1 stamps.

Gates on the merged tree fa19b873: pytest 5,615 passed / 31 skipped / 0 failed;
Swift 746 tests, 0 failures, 1 skipped; eleven translation tables validated
key-for-key; bundle 2.11.1 (2011001) built, installed and driven in light mode.
@youssofal

Copy link
Copy Markdown
Owner

Merged for 2.11.1 with your authorship (commit f47199f): the off-ish reasoning_effort values are accepted. Thank you. Release: https://github.com/youssofal/MTPLX/releases/tag/v2.11.1

@youssofal youssofal closed this Sep 4, 2026
@sypsyp97

Copy link
Copy Markdown
Contributor Author

Thanks for the merge!

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