Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(providers): capture GLM reasoning content on the zhipu provider

Haozhe Wuff04624d13e2
diff --git a/agent/src/providers/capabilities.py b/agent/src/providers/capabilities.py
index 4ad2ebca8..e444465ca 100644
--- a/agent/src/providers/capabilities.py
+++ b/agent/src/providers/capabilities.py
@@ -82,7 +82,17 @@ _KIMI_CODING_CAPABILITIES = ProviderCapabilities(
default_headers={"User-Agent": _KIMI_USER_AGENT},
)
-_ZHIPU_CAPABILITIES = ProviderCapabilities("zhipu", "ZHIPU_API_KEY", "ZHIPU_BASE_URL")
+# GLM thinking models (glm-4.5+/glm-5.x) stream the chain-of-thought as
+# ``reasoning_content`` with the final answer in ``content``. Capture the
+# reasoning like DeepSeek; do NOT replay it on assistant turns —
+# ``send_reasoning_content`` stays off until verified live against bigmodel
+# (DeepSeek rejects replayed reasoning; zhipu is unconfirmed). See #458.
+_ZHIPU_CAPABILITIES = ProviderCapabilities(
+ "zhipu",
+ "ZHIPU_API_KEY",
+ "ZHIPU_BASE_URL",
+ capture_reasoning=True,
+)
_OPENAI_CODEX_CAPABILITIES = ProviderCapabilities("openai-codex", None, "OPENAI_CODEX_BASE_URL")
diff --git a/agent/tests/test_llm.py b/agent/tests/test_llm.py
index 8cc682703..542f8d109 100644
--- a/agent/tests/test_llm.py
+++ b/agent/tests/test_llm.py
@@ -28,7 +28,7 @@ class TestProviderCapabilityAliases:
zhipu_caps.base_url_env,
)
- @pytest.mark.parametrize("model", ["glm-4.6", "glm-5.1"])
+ @pytest.mark.parametrize("model", ["glm-4.6", "glm-5.1", "glm-5.2"])
def test_glm_model_inference_uses_zhipu(self, model: str) -> None:
caps = get_provider_capabilities(provider=None, model=model)
@@ -37,6 +37,18 @@ class TestProviderCapabilityAliases:
def test_glm_provider_env_names_use_zhipu_env(self) -> None:
assert provider_env_names("glm") == ("ZHIPU_API_KEY", "ZHIPU_BASE_URL")
+ def test_zhipu_captures_reasoning_without_replay(self) -> None:
+ """GLM thinking models put chain-of-thought in ``reasoning_content`` (#458).
+
+ Capture must be on so reasoning survives the ChatOpenAI boundary, but
+ replay stays off (DeepSeek posture) until verified live against bigmodel.
+ """
+ for alias in ("zhipu", "glm"):
+ caps = get_provider_capabilities(alias)
+ assert caps.capture_reasoning is True
+ assert caps.send_reasoning_content is False
+ assert caps.normalize_assistant_content is False
+
def test_kimi_coding_uses_own_env_namespace(self) -> None:
caps = get_provider_capabilities("kimi-coding")