fix(zai): add GLM-5.3 support — 1M context window, model lists, reasoning_effort

GLM-5.3 is live on api.z.ai (coding plan endpoint) but had no entries in
Hermes, so it silently fell back to the generic 202K GLM context —
triggering premature context compression on a 1M-window model.

- model_metadata: 'glm-5.3': 1_048_576 (same base model as 5.2; 1M
  context / 128K max output per docs.z.ai/guides/llm/glm-5.3, verified
  2026-08-14)
- auth: add glm-5.3 to coding-plan probe lists (global + CN)
- models: add glm-5.3 to picker/model lists (6 sites)
- zai provider: reasoning_effort mapping covers glm-5.3 (accepted live
  by the endpoint, HTTP 200)
This commit is contained in:
openclaw
2026-08-14 09:26:02 -04:00
committed by Teknium
parent 1bf8bd2c7d
commit 01d8562fce
4 changed files with 30 additions and 16 deletions
+9 -6
View File
@@ -501,16 +501,19 @@ DEFAULT_CONTEXT_LENGTHS = {
# https://platform.minimax.io/docs/api-reference/text-chat-openai
"minimax-m3": 1000000,
"minimax": 204800,
# GLM — GLM-5.2 ships with a 1M context window (verified empirically:
# needle-in-a-haystack retrieval at 789K prompt tokens succeeded with
# zero errors on api.z.ai/api/coding/paas/v4). Older GLM models
# (5, 5.1, 5-turbo) are ~202K. Longest-key-first substring matching
# ensures "glm-5.2" resolves to 1M while older variants still hit the
# generic 202K fallback.
# GLM — GLM-5.2 and GLM-5.3 ship with a 1M context window. GLM-5.2 was
# verified empirically (needle-in-a-haystack retrieval at 789K prompt
# tokens succeeded with zero errors on api.z.ai/api/coding/paas/v4).
# GLM-5.3 uses the same base model (all gains are post-training) with
# 1M context / 128K max output per docs.z.ai/guides/llm/glm-5.3
# (verified 2026-08-14). Older GLM models (5, 5.1, 5-turbo) are ~202K.
# Longest-key-first substring matching ensures "glm-5.2"/"glm-5.3"
# resolve to 1M while older variants still hit the generic 202K fallback.
"glm-5.2": 1_048_576,
# OpenRouter's free GLM-5.2 variant is capped at 256K (live metadata,
# 2026-08-21) — longer key wins over the 1M paid entry above.
"glm-5.2:free": 256_000,
"glm-5.3": 1_048_576,
"glm": 202752,
# xAI Grok — xAI /v1/models does not return context_length metadata,
# so these hardcoded fallbacks prevent Hermes from probing-down to
+2 -2
View File
@@ -743,8 +743,8 @@ ZAI_ENDPOINTS = [
# (id, base_url, probe_models, label)
("global", "https://api.z.ai/api/paas/v4", ["glm-5"], "Global"),
("cn", "https://open.bigmodel.cn/api/paas/v4", ["glm-5"], "China"),
("coding-global", "https://api.z.ai/api/coding/paas/v4", ["glm-5.2", "glm-5.1", "glm-5v-turbo", "glm-4.7"], "Global (Coding Plan)"),
("coding-cn", "https://open.bigmodel.cn/api/coding/paas/v4", ["glm-5.2", "glm-5.1", "glm-5v-turbo", "glm-4.7"], "China (Coding Plan)"),
("coding-global", "https://api.z.ai/api/coding/paas/v4", ["glm-5.3", "glm-5.2", "glm-5.1", "glm-5v-turbo", "glm-4.7"], "Global (Coding Plan)"),
("coding-cn", "https://open.bigmodel.cn/api/coding/paas/v4", ["glm-5.3", "glm-5.2", "glm-5.1", "glm-5v-turbo", "glm-4.7"], "China (Coding Plan)"),
]
+6 -1
View File
@@ -116,7 +116,8 @@ OPENROUTER_MODELS: list[tuple[str, str]] = [
# MiniMax
("minimax/minimax-m3", ""),
# Z-AI
("z-ai/glm-5.2", "default"),
("z-ai/glm-5.3", "default"),
("z-ai/glm-5.2", ""),
("z-ai/glm-5.1", ""),
# Xiaomi
("xiaomi/mimo-v2.5-pro", ""),
@@ -294,6 +295,7 @@ _PROVIDER_MODELS: dict[str, list[str]] = {
# MiniMax
"minimax/minimax-m3",
# Z-AI
"z-ai/glm-5.3",
"z-ai/glm-5.2",
"z-ai/glm-5.1",
# Xiaomi
@@ -373,6 +375,7 @@ _PROVIDER_MODELS: dict[str, list[str]] = {
"gemini-3.1-flash-lite-preview",
],
"zai": [
"glm-5.3",
"glm-5.2",
"glm-5.1",
"glm-5",
@@ -391,6 +394,7 @@ _PROVIDER_MODELS: dict[str, list[str]] = {
"nvidia/nemotron-3-nano-omni-30b-a3b-reasoning",
# Third-party agentic models hosted on build.nvidia.com
# (map to OpenRouter defaults — users get familiar picks on NIM)
"z-ai/glm-5.3",
"z-ai/glm-5.2",
"moonshotai/kimi-k2.6",
"minimaxai/minimax-m3",
@@ -542,6 +546,7 @@ _PROVIDER_MODELS: dict[str, list[str]] = {
"minimax-m3",
"minimax-m2.7",
"minimax-m2.5",
"glm-5.3",
"glm-5.2",
"glm-5.1",
"glm-5",
+13 -7
View File
@@ -47,22 +47,28 @@ def _model_supports_thinking(model: str | None) -> bool:
def _is_glm_5_2(model: str | None) -> bool:
"""Detect GLM-5.2 across the alias spellings providers use.
"""Detect GLM-5.2/5.3 (reasoning_effort-capable) across alias spellings.
Covers the canonical ``glm-5.2`` plus the ``glm-5-2`` / ``glm-5p2``
variants seen on relays (Fireworks ``glm-5p2``, etc.) and any
vendor-prefixed form (``z-ai/glm-5.2``, ``zai-org-glm-5-2``).
Covers the canonical ``glm-5.2``/``glm-5.3`` plus the ``glm-5-2`` /
``glm-5p2`` variants seen on relays (Fireworks ``glm-5p2``, etc.) and any
vendor-prefixed form (``z-ai/glm-5.2``, ``zai-org-glm-5-2``). GLM-5.3
uses the same base model as 5.2 (post-training gains only) and exposes
the same ``reasoning_effort`` knob (verified live 2026-08-14: the
coding-plan endpoint accepts ``reasoning_effort: high`` for glm-5.3).
"""
m = (model or "").strip().lower()
if not m:
return False
return any(token in m for token in ("glm-5.2", "glm-5-2", "glm-5p2"))
return any(
token in m
for token in ("glm-5.2", "glm-5-2", "glm-5p2", "glm-5.3", "glm-5-3", "glm-5p3")
)
def _glm_5_2_reasoning_effort(reasoning_config: dict | None) -> str | None:
"""Map Hermes reasoning effort onto GLM-5.2's native ``high``/``max``.
"""Map Hermes reasoning effort onto GLM-5.2/5.3's native ``high``/``max``.
GLM-5.2 only supports two enabled effort levels. ``xhigh``/``max``/``ultra``
These models only support two enabled effort levels. ``xhigh``/``max``/``ultra``
request the top tier; everything else that is enabled requests ``high``
(its minimum thinking level). When reasoning is explicitly disabled, or
no effort preference is supplied, the server default is left untouched.