feat(providers): GLM-5.2 native reasoning_effort controls (#58884)

Port from Kilo-Org/kilocode#11555: GLM-5.2 exposes a native
reasoning_effort knob with two enabled levels (high / max) on its
OpenAI-compatible endpoints. Previously the zai profile (direct Z.AI
/api/paas/v4) used the base ProviderProfile and emitted nothing, and the
OpenCode Go profile only handled Kimi K2 / DeepSeek — so a user's effort
preference for GLM-5.2 was silently dropped on both routes.

- zai: ZaiProfile maps effort onto high/max (xhigh/max -> max, lower -> high)
- opencode-go: same mapping for GLM-5.2, alongside existing Kimi/DeepSeek
- alias spellings recognized (glm-5.2 / glm-5-2 / glm-5p2, vendor-prefixed)
- disabled / no effort leaves the server default untouched
This commit is contained in:
Teknium 2026-07-05 13:48:01 -07:00 committed by GitHub
parent ba31699091
commit a6079dd350
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 242 additions and 10 deletions

View file

@ -122,13 +122,68 @@ class TestOpenCodeGoDeepSeekThinking:
assert top_level == {"reasoning_effort": "max"}
class TestOpenCodeGoGLM52Reasoning:
"""GLM-5.2 uses its native high/max reasoning_effort knob on OpenCode Go."""
def test_high_maps_to_high(self, opencode_go_profile):
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
reasoning_config={"enabled": True, "effort": "high"},
model="glm-5.2",
)
assert extra_body == {}
assert top_level == {"reasoning_effort": "high"}
def test_low_and_medium_clamp_up_to_high(self, opencode_go_profile):
for effort in ("low", "medium", "minimal"):
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
reasoning_config={"enabled": True, "effort": effort},
model="glm-5.2",
)
assert extra_body == {}
assert top_level == {"reasoning_effort": "high"}
def test_xhigh_and_max_map_to_max(self, opencode_go_profile):
for effort in ("xhigh", "max"):
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
reasoning_config={"enabled": True, "effort": effort},
model="z-ai/glm-5.2",
)
assert extra_body == {}
assert top_level == {"reasoning_effort": "max"}
def test_disabled_leaves_server_default(self, opencode_go_profile):
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
reasoning_config={"enabled": False, "effort": "high"},
model="glm-5.2",
)
assert extra_body == {}
assert top_level == {}
def test_no_config_leaves_server_default(self, opencode_go_profile):
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
reasoning_config=None,
model="glm-5.2",
)
assert extra_body == {}
assert top_level == {}
@pytest.mark.parametrize("model", ["glm-5-2", "glm-5p2"])
def test_alias_spellings_recognized(self, opencode_go_profile, model):
extra_body, top_level = opencode_go_profile.build_api_kwargs_extras(
reasoning_config={"enabled": True, "effort": "max"},
model=model,
)
assert top_level == {"reasoning_effort": "max"}
class TestOpenCodeGoModelGating:
"""Other OpenCode Go models must not receive Kimi/DeepSeek controls."""
"""Other OpenCode Go models must not receive Kimi/DeepSeek/GLM controls."""
@pytest.mark.parametrize(
"model",
[
"glm-5.1",
"glm-5",
"qwen3.6-plus",
"minimax-m2.7",
"deepseek-v3.1",