fix(custom-provider): forward reasoning_effort at the live profile path (GLM-5.2/ARK) - #58156
Merged
Merged
Conversation
- Add 'max' to VALID_REASONING_EFFORTS (GLM-5.2 native parameter) - Emit top-level reasoning_effort string for custom providers - Stop hardcoding 'medium' in legacy extra_body.reasoning, use actual effort Custom providers (e.g. GLM-5.2 on Volcengine ARK) silently dropped reasoning_effort — the value never reached the upstream API. Kimi, TokenHub, and LM Studio all had dedicated branches for this, but custom providers had none.
Follow-up to salvaged NousResearch#57601. Adding "max" to VALID_REASONING_EFFORTS made parse_reasoning_effort("max") valid, so: - test_unknown_levels_return_none no longer lists "max" (it is now valid; auto-covered by test_each_valid_level which iterates the tuple). - test_known_supported_levels_are_documented and the parse_reasoning_effort docstring now include "max" so the doc-sync guard actually protects it.
PR NousResearch#57601's original branch added a top-level reasoning_effort emit to the LEGACY build_kwargs path (agent/transports/chat_completions.py), but provider=custom resolves to CustomProfile (plugins/model-providers/custom/), so chat_completion_helpers takes the profile path and returns early — the added branch was unreachable dead code for every custom endpoint. Move the fix to its real site, CustomProfile.build_api_kwargs_extras(), and follow the DeepSeek/Zai profile precedent: - disabled -> extra_body.think = False (unchanged) - enabled + effort -> TOP-LEVEL reasoning_effort (the OpenAI-compatible format GLM-5.2/ARK expect), passed through verbatim incl. max/xhigh - enabled + no effort -> omit, so the endpoint's server default applies (avoids silently forcing 'medium' as the original branch did) Deliberately does NOT force think=True on enable — that flag is Ollama-only and risks a 400 on GLM/vLLM endpoints that don't recognize it; thinking is already server-default-on for these backends. Verified end-to-end through the real profile dispatch (temp HERMES_HOME): custom+high -> reasoning_effort=high; custom+max -> reasoning_effort=max; custom+none -> think=False; custom+unset -> nothing; num_ctx composes. Adds tests/plugins/model_providers/test_custom_profile.py (13 cases). Addresses the custom-provider half of NousResearch#55276. Co-authored-by: huanshan5195 <huanshan5195@users.noreply.github.com>
check-attribution requires every contributor author email to be in AUTHOR_MAP; the salvaged commit is authored by huanshan5195 <huanshan5195@users.noreply.github.com>.
This was referenced Jul 14, 2026
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes
reasoning_effortactually reachprovider=customOpenAI-compatible endpoints (GLM-5.2 on Volcengine ARK, vLLM, Ollama, llama.cpp), where it was silently dropped — salvaged from @huanshan5195's #57601, relocated to the live code path plus tests.Root cause: the fix must live in
CustomProfile.build_api_kwargs_extras(), not the legacybuild_kwargsbranch #57601 originally patched.provider=customresolves toCustomProfile, sochat_completion_helperstakes the profile path and returns early — #57601's branch was unreachable dead code for every custom endpoint (verified E2E).Changes
plugins/model-providers/custom/__init__.py: on reasoning enabled + effort, emit a top-levelreasoning_effort(the OpenAI-compatible format GLM/ARK expect), passed through verbatim incl.max/xhigh; disabled still sendsextra_body.think=False; enabled + no effort omits both so the endpoint's server default applies. Follows the DeepSeek/Zai profile precedent — does not forcethink=Trueon enable (Ollama-only flag, risks 400 on GLM/vLLM).hermes_constants.py: add"max"toVALID_REASONING_EFFORTS(GLM-5.2's native deep-reasoning level) — from fix: forward reasoning_effort for custom providers (GLM-5.2 on ARK) #57601.agent/transports/chat_completions.py: stop hardcodingeffort:"medium"in the legacyextra_body.reasoningfallback; use the user's configured effort — from fix: forward reasoning_effort for custom providers (GLM-5.2 on ARK) #57601.is_custom_providerlegacy branch.tests/plugins/model_providers/test_custom_profile.py(13 cases); updatedtests/test_hermes_constants.pydoc-sync guards formax.Validation
reasoning_effort: highreasoning_effort: highreasoning_effort: maxreasoning_effort: maxreasoning_effort: nonethink: Falsethink: FalseVerified end-to-end through the real profile dispatch with a temp
HERMES_HOME(16/16 smoke cases incl. dirty/whitespace/uppercase effort strings). Targeted suites green: 254 tests (test_custom_profile,test_hermes_constants,test_chat_completions,test_provider_profiles,test_transport_parity). ruff clean; ty net-new = 0.Review notes (hermes-pr-review Phase 2c)
"max"effort passthrough is a widened value set on a pre-existing tolerant path, not a new failure mode. The OpenRouter profile's non-Anthropic route already passedxhighverbatim intoextra_body.reasoningbefore this PR;maxnow rides the same path. OpenRouter clamps/ignores unknown effort rather than 400-ing. No livemaxprobe on a non-Anthropic OpenRouter route — the safety argument rests on OpenRouter's documented tolerance and the pre-existingxhighprecedent. The un-hardcoded legacyextra_body.reasoningbranch is reached by no registered provider (all resolve via profiles; LM Studio is explicitly excluded).xhigh/max→maxnormalization) is a deliberate choice for a generic custom endpoint — the profile can't know an arbitrary backend's effort vocabulary, and GLM's native levels arehigh/max. Documented in the code.provider=zaipath still drops effort-on-enable (ZaiProfileemits onlythinking={enabled|disabled}). That's the other half of reasoning_effort / thinking_budget silently dropped for custom and zai providers #55276, already tracked by [Feature]: Add GLM-5 reasoning support to direct ZAI provider #50696 and PRs feat(zai): wire reasoning_effort for GLM-5.x thinking models #48004/feat(zai): support thinking effort for GLM-5.2 #46446 — not addressed here.Addresses the custom-provider half of #55276. Closes #57601 (salvaged, authorship preserved).
Co-authored-by: huanshan5195 huanshan5195@users.noreply.github.com