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.

A Hermes result names the served model and carries the provider's cache split through the relay (#354)

github-actions[bot]5e4aab37b62e
diff --git a/gateway/app.py b/gateway/app.py
index fb730305..89a3be5e 100644
--- a/gateway/app.py
+++ b/gateway/app.py
@@ -17478,14 +17478,14 @@ async def list_bases(request: Request) -> dict:
for bid, b in _BASE_CATALOG.items():
backend = b["backend"]
cat = _MODEL_CATALOG.get(backend, {})
- servable = await _servable_models(org, backend)
- ok = (lambda m: True) if servable is None else (lambda m: m in servable)
+ # the same view every picker reads (see list_models): catalog, custom endpoints, additions
+ view = await _harness_models_view({}, backend, await _servable_models(org, backend))
out.append({
"id": bid, "object": "harness.base", "label": b["label"], "backend": backend,
"status": b["status"], "systemPrompt": b["system_prompt"],
"defaultModel": cat.get("default", ""),
- "models": [{"id": m, "available": ok(m), "default": m == cat.get("default")}
- for m in cat.get("models", [])],
+ "models": [{"id": m["id"], "available": m["available"], "default": m["default"]}
+ for m in view["models"]],
"tools": [{"name": n, "label": lbl, "enforcement": b["tool_enforcement"]}
for n, lbl in b["tools"]],
# Skills bundled into the image, which every base can use. A base ALSO discovers
@@ -17512,35 +17512,14 @@ async def list_models(request: Request) -> dict:
org, _ = await _pub_org_member(request)
# `available` is computed, not asserted: a model with no provider behind it is listed as
# unavailable so a picker can disable it, instead of offering a choice that fails at run time.
+ # ONE VIEW for every picker: the harness route's (_harness_models_view), which also lists a
+ # custom endpoint's models and the models an operator added to a vendor integration on the
+ # backends they drive. A second copy of that logic here listed custom endpoints only, so an
+ # added model ran but never showed on a base's picker (hr-test, 2026-09-30).
out = {}
- # Custom integration models: pulled from the effective model map so they appear in the
- # picker for every backend that can serve them. A chain (servable=None) is the FALLBACK
- # for models without a mapping; a model WITH a mapping (custom or otherwise) is still
- # routable, so it must still be shown.
- eff_map = await _effective_model_map()
- integrations = {str(i.get("name") or ""): i for i in await _integrations_doc()}
for b, c in _MODEL_CATALOG.items():
- servable = await _servable_models(org, b)
- ok = (lambda m: True) if servable is None else (lambda m: m in servable)
- models = [{"id": m, "label": m, "backend": b, "available": ok(m),
- "default": m == c["default"]} for m in c["models"]]
- seen = set(c["models"])
- # Add models from the effective map that are not already in the catalog: a custom
- # endpoint's model, on the backends its api_format drives. Not on the others, not even
- # greyed: a Claude model under Codex read as "Codex can use Anthropic models" (Richard,
- # hr-test 2026-09-27), and a backend that can never run a model has no row for it.
- for canonical, iname in eff_map.items():
- if canonical in seen:
- continue
- integ = integrations.get(iname)
- # Custom integrations only — same reasoning as _harness_models_view above.
- if not integ or str(integ.get("provider") or "").lower() != "custom":
- continue
- if _integration_serves_backend(integ, b):
- models.append({"id": canonical, "label": canonical, "backend": b,
- "available": True, "default": False})
- seen.add(canonical)
- out[b] = {"default": c["default"], "models": models}
+ view = await _harness_models_view({}, b, await _servable_models(org, b))
+ out[b] = {"default": c["default"], "models": view["models"]}
return {"backends": out}
diff --git a/gateway/tests/test_model_refusal.py b/gateway/tests/test_model_refusal.py
index 13a0020c..aebded5e 100644
--- a/gateway/tests/test_model_refusal.py
+++ b/gateway/tests/test_model_refusal.py
@@ -99,3 +99,14 @@ def test_a_custom_messages_endpoint_drives_the_three_bases_that_now_speak_it():
for b in ("goose", "hermes", "openhands"):
assert b in gw._CUSTOM_FORMAT_BACKENDS["anthropic"]
assert "codex" not in gw._CUSTOM_FORMAT_BACKENDS["anthropic"]
+
+
+def test_every_picker_reads_the_one_view():
+ """/v1/models and /v1/bases feed the base pickers; a second copy of the harness route's logic
+ listed custom endpoints only, so a model added to a vendor integration ran but never showed."""
+ src = Path(gw.__file__).read_text()
+ models_route = src[src.index('@app.get("/v1/models")'):src.index('@app.get("/v1/harnesses/{hid}/models")')]
+ bases_route = src[src.index('@app.get("/v1/bases")'):src.index('"builtinSkillsEnumerable": False')]
+ assert "await _harness_models_view({}, b, await _servable_models(org, b))" in models_route
+ assert "await _harness_models_view({}, backend, await _servable_models(org, backend))" in bases_route
+ assert 'provider") or "").lower() != "custom"' not in models_route
diff --git a/runner/server.py b/runner/server.py
index 029fd6f2..7c0795fc 100644
--- a/runner/server.py
+++ b/runner/server.py
@@ -7457,8 +7457,16 @@ def _run_hermes_bg(turn_id: str, cwd: str, env: dict, model: str, provider: str,
f"turn was stopped. The provider call hung before returning anything.\n{err_txt}"
)[:2000]
res_txt = final if ok else ("\n\n".join(x for x in (final.strip(), err_txt) if x)[:4000] or err_txt)
- append({"type": "result", "subtype": "success" if ok else "error", "is_error": not ok,
- "result": res_txt, "usage": usage})
+ ev = {"type": "result", "subtype": "success" if ok else "error", "is_error": not ok,
+ "result": res_txt, "usage": usage}
+ # What the relay saw the provider say: the served model, and the usage with its cache split.
+ # hermes's session counters carry no cache figures, so a Claude turn through the relay read as
+ # uncached and unlabelled on the result (hr-test, 2026-09-30) while the provider had cached it.
+ served = _relay_served_model(env)
+ if served:
+ ev["model"] = served
+ _fill_relay_usage(ev, env)
+ append(ev)
rec["exit_code"] = rc
rec["result"] = final
rec["status"] = ("cancelled" if rec.get("cancelled") else "timeout" if rec.get("capped")
diff --git a/runner/tests/test_messages_route.py b/runner/tests/test_messages_route.py
index 27176eed..71076413 100644
--- a/runner/tests/test_messages_route.py
+++ b/runner/tests/test_messages_route.py
@@ -181,3 +181,12 @@ def test_the_claude_result_names_the_model_from_its_usage_by_model():
assert out[0]["model"] == "claude-sonnet-4-6"
named = server._claude_passthrough({"type": "result", "model": "x", "modelUsage": res["modelUsage"]}, {})
assert named[0]["model"] == "x"
+
+
+def test_the_hermes_result_carries_the_relays_served_model_and_cache_split():
+ """hermes builds its own result from its session counters, which carry no cache figures and no
+ model; through the relay the provider's statement is at hand and is what prices the turn."""
+ src = pathlib.Path(__file__).resolve().parents[1].joinpath("server.py").read_text()
+ body = src[src.index("def _run_hermes_bg("):src.index("# ── HTTP surface")]
+ assert "served = _relay_served_model(env)" in body and "_fill_relay_usage(ev, env)" in body
+ assert body.index("_fill_relay_usage(ev, env)") < body.rindex("append(ev)") # stamped before the result is appended
diff --git a/runner/tests/test_relay_usage.py b/runner/tests/test_relay_usage.py
index f2e276ee..b37dacc1 100644
--- a/runner/tests/test_relay_usage.py
+++ b/runner/tests/test_relay_usage.py
@@ -127,5 +127,5 @@ def test_a_backend_that_reports_its_own_usage_keeps_it():
split count (codex, claude) is the record. Pinned on the source of the run loop, which needs
a live process to exercise: both result sites go through the one helper."""
src = pathlib.Path(__file__).resolve().parents[1].joinpath("server.py").read_text()
- assert src.count("_fill_relay_usage(ev, env)") == 2
+ assert src.count("_fill_relay_usage(ev, env)") == 3 # the run loop, its eof path, the hermes driver
assert src.count('if ev.get("type") == "result" and not ev.get("usage"):') == 0