Skip to content

Your lightweight open-source personal agent.

fix(providers): honor disabled thinking for supported GLM models

Kail Tian8c8fbc7a05ce
diff --git a/nanobot/providers/openai_compat_provider.py b/nanobot/providers/openai_compat_provider.py
index f040900e4..dab97f481 100644
--- a/nanobot/providers/openai_compat_provider.py
+++ b/nanobot/providers/openai_compat_provider.py
@@ -168,6 +168,11 @@ def _thinking_styles_for(spec: ProviderSpec | None, model_name: str) -> list[str
styles: list[str] = []
if spec and spec.thinking_style:
styles.append(spec.thinking_style)
+ elif spec and spec.name == "zhipu" and _model_slug(model_name) in {
+ "glm-4.6", "glm-4.7", "glm-5", "glm-5.1", "glm-5.2",
+ }:
+ # Keep this model-specific: GLM-5.3 requires thinking and cannot disable it.
+ styles.append("thinking_type")
model_style = _model_thinking_style(model_name)
if model_style and model_style not in styles:
styles.append(model_style)
diff --git a/tests/providers/test_openai_compat_spec.py b/tests/providers/test_openai_compat_spec.py
index 1d4847aec..32674642b 100644
--- a/tests/providers/test_openai_compat_spec.py
+++ b/tests/providers/test_openai_compat_spec.py
@@ -1485,6 +1485,26 @@ def _build_kwargs_for(provider_name: str, model: str, reasoning_effort=None):
)
[email protected]("provider, model, effort, thinking_type", [
+ ("zhipu", "glm-4.6", "none", "disabled"),
+ ("zhipu", "glm-4.7", "none", "disabled"),
+ ("zhipu", "glm-5", "none", "disabled"),
+ ("zhipu", "glm-5.1", "none", "disabled"),
+ ("zhipu", "glm-5.2", "none", "disabled"),
+ ("zhipu", "glm-5.2", "minimal", "disabled"),
+ ("zhipu", "glm-4.7", "high", "enabled"),
+ ("zhipu", "glm-4.7", None, None),
+ ("zhipu", "glm-5.3", "none", None),
+ ("zhipu", "glm-5.3-flash", "none", None),
+ ("custom", "glm-4.7", "none", None),
+])
+def test_zhipu_glm_thinking_controls(provider, model, effort, thinking_type) -> None:
+ kw = _build_kwargs_for(provider, model, reasoning_effort=effort)
+ assert kw.get("extra_body", {}).get("thinking", {}).get("type") == thinking_type
+ if effort == "none":
+ assert "reasoning_effort" not in kw
+
+
def test_dashscope_thinking_enabled_with_reasoning_effort() -> None:
kw = _build_kwargs_for("dashscope", "qwen3-plus", reasoning_effort="medium")
assert kw["extra_body"] == {"enable_thinking": True}