Skip to content

fix(custom-provider): forward reasoning_effort at the live profile path (GLM-5.2/ARK) - #58156

Merged
kshitijk4poor merged 4 commits into
NousResearch:mainfrom
kshitijk4poor:review-57601
Jul 4, 2026
Merged

fix(custom-provider): forward reasoning_effort at the live profile path (GLM-5.2/ARK)#58156
kshitijk4poor merged 4 commits into
NousResearch:mainfrom
kshitijk4poor:review-57601

Conversation

@kshitijk4poor

@kshitijk4poor kshitijk4poor commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

Makes reasoning_effort actually reach provider=custom OpenAI-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 legacy build_kwargs branch #57601 originally patched. provider=custom resolves to CustomProfile, so chat_completion_helpers takes 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-level reasoning_effort (the OpenAI-compatible format GLM/ARK expect), passed through verbatim incl. max/xhigh; disabled still sends extra_body.think=False; enabled + no effort omits both so the endpoint's server default applies. Follows the DeepSeek/Zai profile precedent — does not force think=True on enable (Ollama-only flag, risks 400 on GLM/vLLM).
  • hermes_constants.py: add "max" to VALID_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 hardcoding effort:"medium" in the legacy extra_body.reasoning fallback; use the user's configured effort — from fix: forward reasoning_effort for custom providers (GLM-5.2 on ARK) #57601.
  • Removed fix: forward reasoning_effort for custom providers (GLM-5.2 on ARK) #57601's unreachable is_custom_provider legacy branch.
  • Tests: new tests/plugins/model_providers/test_custom_profile.py (13 cases); updated tests/test_hermes_constants.py doc-sync guards for max.

Validation

provider=custom Before (main) After
reasoning_effort: high (nothing sent) top-level reasoning_effort: high
reasoning_effort: max (rejected → nothing) top-level reasoning_effort: max
reasoning_effort: none think: False think: False
(unset) (nothing) (nothing — server default)

Verified 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)

Addresses the custom-provider half of #55276. Closes #57601 (salvaged, authorship preserved).

Co-authored-by: huanshan5195 huanshan5195@users.noreply.github.com

huanshan5195 and others added 4 commits July 4, 2026 13:55
- 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>.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/zai ZAI provider P2 Medium — degraded but workaround exists labels Jul 4, 2026
@kshitijk4poor
kshitijk4poor merged commit 3c8c968 into NousResearch:main Jul 4, 2026
60 of 61 checks passed
@kshitijk4poor
kshitijk4poor deleted the review-57601 branch August 5, 2026 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P2 Medium — degraded but workaround exists provider/zai ZAI provider type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants