Skip to content

HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.

fix(gateway): the picker offered models the org cannot serve; add glm-5.3

richard-epsilla8d727f169ea6
diff --git a/gateway/app.py b/gateway/app.py
index 5baeae2d..6097ba5a 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -4316,6 +4316,8 @@ _VENDOR_MODELS: dict[str, dict[str, str]] = {
"deepseek-v4-pro": "deepseek/deepseek-v4-pro",
"deepseek-v4-flash": "deepseek/deepseek-v4-flash",
"kimi-k3": "moonshotai/kimi-k3",
+ "glm-5.3": "z-ai/glm-5.3",
+ "glm-5.3-flash": "z-ai/glm-5.3-flash",
"qwen3.7-max": "qwen/qwen3.7-max",
"qwen3.8-max": "qwen/qwen3.8-max",
"kimi-k2.7-code": "moonshotai/kimi-k2.7-code",
@@ -4404,6 +4406,8 @@ _VENDOR_MODELS: dict[str, dict[str, str]] = {
"deepseek-v4-pro": "deepseek/deepseek-v4-pro",
"deepseek-v4-flash": "deepseek/deepseek-v4-flash",
"kimi-k3": "moonshot/kimi-k3",
+ "glm-5.3": "z-ai/glm-5.3",
+ "glm-5.3-flash": "z-ai/glm-5.3-flash",
"qwen3.7-max": "qwen/qwen3.7-max",
"qwen3.8-max": "qwen/qwen3.8-max",
"kimi-k2.7-code": "moonshot/kimi-k2.7-code",
@@ -4465,6 +4469,9 @@ _VERCEL_RESLUG = {
"qwen3.8-max": "alibaba/qwen3.8-max",
"qwen3.7-flash": "alibaba/qwen3.7-flash",
"mistral-medium-3.5": "mistral/mistral-medium-3.5",
+ # Vercel publishes the z-ai models under `zai/`, not the `z-ai/` the other aggregators use.
+ "glm-5.3": "zai/glm-5.3",
+ "glm-5.3-flash": "zai/glm-5.3-flash",
}
_VENDOR_MODELS["vercel"] = {c: _VERCEL_RESLUG.get(c, v)
for c, v in _VENDOR_MODELS["openrouter"].items()}
@@ -4571,7 +4578,7 @@ _MODEL_CATALOG: dict[str, dict] = {
# frontier US+China set, served via the TokenRouter/OpenRouter
# integrations (2026-07-22: each probe-verified through the hermes
# CLI on the TokenRouter connection)
- "gemini-3.6-flash", "deepseek-v4-pro", "deepseek-v4-flash", "kimi-k3",
+ "gemini-3.6-flash", "deepseek-v4-pro", "deepseek-v4-flash", "kimi-k3", "glm-5.3", "glm-5.3-flash",
"qwen3.7-max", "qwen3.8-max", "kimi-k2.7-code",
"mistral-medium-3.5", "step-3.7-flash", "minimax-m3",
"nemotron-3-ultra", "hunyuan-3", "ling-3.0-flash",
@@ -4600,7 +4607,7 @@ _MODEL_CATALOG: dict[str, dict] = {
"gpt-5.4", "gpt-5.4-mini", "gpt-5.2", "gpt-5.3-codex",
"claude-opus-5", "claude-fable-5", "claude-opus-4.8", "claude-sonnet-5",
"claude-opus-4.7", "claude-sonnet-4.6", "claude-haiku-4.5",
- "gemini-3.6-flash", "kimi-k3", "kimi-k2.7-code",
+ "gemini-3.6-flash", "kimi-k3", "glm-5.3", "glm-5.3-flash", "kimi-k2.7-code",
"qwen3.7-max", "qwen3.8-max",
"mistral-medium-3.5", "step-3.7-flash"]},
# opencode reaches every model the same way pi does: one OpenAI-compatible (or Messages, or
@@ -4615,7 +4622,7 @@ _MODEL_CATALOG: dict[str, dict] = {
"gpt-5.4", "gpt-5.4-mini", "gpt-5.2", "gpt-5.3-codex",
"claude-opus-5", "claude-fable-5", "claude-opus-4.8", "claude-sonnet-5",
"claude-opus-4.7", "claude-sonnet-4.6", "claude-haiku-4.5",
- "gemini-3.6-flash", "deepseek-v4-pro", "deepseek-v4-flash", "kimi-k3",
+ "gemini-3.6-flash", "deepseek-v4-pro", "deepseek-v4-flash", "kimi-k3", "glm-5.3", "glm-5.3-flash",
"kimi-k2.7-code", "qwen3.7-max", "qwen3.8-max",
"mistral-medium-3.5", "step-3.7-flash"]},
# qwen-code speaks OPENAI_BASE_URL/OPENAI_API_KEY at the same relays; serving paths are pi's.
@@ -4814,22 +4821,35 @@ async def _resolve_model_policy(requested: str, hv: dict | None, backend: str, o
async def _servable_models(org: str | None, backend: str) -> set[str] | None:
"""Canonical models something can actually run on this backend.
- None means "no restriction": a policy chain exists, and a chain's connections are
- provider-level rather than per-model, so the backend can attempt its whole catalog.
-
- Otherwise the only thing that can serve a turn is a model→integration mapping, so the
- answer is exactly those canonicals whose integration's provider is wired to this backend.
- Offering a model nothing can serve is a promise the router then breaks — the picker would
- accept it and the turn would fail at the point of no return."""
- if await _resolve_chain(org, backend, None):
- return None
+ The answer is the UNION of the two ways a turn can actually be served: the vendor tables of
+ the policy chain's connections, and the model→integration map. Offering a model nothing can
+ serve is a promise the router then breaks — the picker accepts it and the turn fails at the
+ point of no return.
+
+ A chain used to mean "no restriction", on the reasoning that a chain is provider-level rather
+ than per-model. The vendor tables are per-model and deliberately differ:
+ _TOKENROUTER_NO_CHANNEL removes five models from TokenRouter's table precisely because it
+ serves no channel for them. A user picked one and the turn died after the point of no return.
+
+ Both halves of the union are load-bearing, each learned by breaking it:
+ • chain only — greys out models an org runs daily through an explicit integration mapping.
+ • map only — the original bug; a chain-served org gets its whole catalog offered.
+ An unknown vendor still means no restriction: not-in-our-tables is ignorance, not evidence
+ that a model cannot be served, and restricting on ignorance silently hides working models."""
integrations = {str(i.get("name") or ""): i for i in await _integrations_doc()}
servable: set[str] = set()
+ # A chain names VAULT connections (harness-conn-<name>), NOT entries in the integrations doc.
+ # Looking them up in the doc misses every time, and "not found" then reads as "unknown vendor",
+ # so the restriction silently restricts nothing.
+ for name in await _resolve_chain(org, backend, None):
+ conn, _tenant = await _get_connection(org, name)
+ table = _vendor_models(str((conn or {}).get("provider") or "").lower())
+ if not table:
+ return None
+ servable |= set(table)
for canonical, iname in (await _effective_model_map()).items():
integ = integrations.get(iname)
- if not integ:
- continue
- if _integration_serves_backend(integ, backend):
+ if integ and _integration_serves_backend(integ, backend):
servable.add(canonical)
return servable
diff --git a/gateway/tests/test_servable_models.py b/gateway/tests/test_servable_models.py
new file mode 100644
index 00000000..e4ec1a9f
--- /dev/null
+++ b/gateway/tests/test_servable_models.py
@@ -0,0 +1,75 @@
+"""What the model picker may offer.
+
+A user picked a model the picker showed, the turn was accepted, and it failed after the point of
+no return — TokenRouter serves no channel for it (_TOKENROUTER_NO_CHANNEL). _servable_models had
+answered "no restriction" for any org with a policy chain, on the reasoning that a chain is
+provider-level rather than per-model. The vendor tables ARE per-model and deliberately differ.
+
+Both halves of the union below are load-bearing, and each was learned by breaking it:
+ * chain only — greys out models an org runs daily through an explicit integration mapping.
+ * map only — the original bug: a chain-served org gets its entire catalog offered.
+"""
+import pathlib
+import sys
+
+import pytest
+
+sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
+import app as A # noqa: E402
+
+
+def _patch(monkeypatch, *, chain=(), conn_provider=None, model_map=None, integrations=()):
+ async def _chain(_org, _backend, _explicit):
+ return list(chain)
+
+ async def _conn(_org, _name):
+ return ({"provider": conn_provider} if conn_provider else None), None
+
+ async def _map():
+ return dict(model_map or {})
+
+ async def _docs():
+ return list(integrations)
+
+ monkeypatch.setattr(A, "_resolve_chain", _chain)
+ monkeypatch.setattr(A, "_get_connection", _conn)
+ monkeypatch.setattr(A, "_effective_model_map", _map)
+ monkeypatch.setattr(A, "_integrations_doc", _docs)
+
+
+async def test_a_chain_restricts_to_what_that_vendor_actually_serves(monkeypatch):
+ _patch(monkeypatch, chain=["tr"], conn_provider="tokenrouter")
+ got = await A._servable_models("org", "hermes")
+ assert got is not None, "a chain must no longer mean 'offer everything'"
+ # the five with no channel are exactly what must not be offered
+ assert got.isdisjoint(A._TOKENROUTER_NO_CHANNEL)
+ assert "claude-sonnet-4.6" in got and "kimi-k3" in got
+
+
+async def test_an_explicitly_mapped_model_stays_available_alongside_a_chain(monkeypatch):
+ """The regression the union prevents: answering from the chain alone greyed out models an
+ org runs daily through its own integration mapping."""
+ integ = {"name": "Router", "provider": "tokenrouter"}
+ _patch(monkeypatch, chain=["tr"], conn_provider="tokenrouter",
+ model_map={"minimax-m3": "Router"}, integrations=[integ])
+ monkeypatch.setattr(A, "_integration_serves_backend", lambda _i, _b: True)
+ got = await A._servable_models("org", "hermes")
+ assert "minimax-m3" in got
+
+
+async def test_an_unknown_vendor_does_not_restrict(monkeypatch):
+ """Not-in-our-tables is ignorance, not evidence a model cannot be served. Restricting on it
+ would silently hide working models."""
+ _patch(monkeypatch, chain=["mystery"], conn_provider="something-we-never-heard-of")
+ assert await A._servable_models("org", "hermes") is None
+
+
+async def test_no_chain_still_answers_from_the_map(monkeypatch):
+ integ = {"name": "Vercel", "provider": "vercel"}
+ _patch(monkeypatch, chain=[], model_map={"gpt-5.4": "Vercel"}, integrations=[integ])
+ monkeypatch.setattr(A, "_integration_serves_backend", lambda _i, _b: True)
+ assert await A._servable_models("org", "codex") == {"gpt-5.4"}