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.
Python agent-apiagent-frameworkagent-harnessai-agentsai-infrastructurecoding-agentconformance-testingdeepseek-harnessharness-engineeringhermesllmopen-protocolopen-sourceopen-standardpi-coding-agentself-hosteduhpunified-apiunified-harness-protocolunified-interface
fix(hermes): vision is a capability of the instance, not a property of the writing model
richard-epsilla77fbac1f6061
diff --git a/gateway/app.py b/gateway/app.pyindex c977abcb..509f127d 100644--- a/gateway/app.py+++ b/gateway/app.py@@ -4463,6 +4463,53 @@ _TEXT_ONLY_INPUT = {"qwen3.7-max"}_PROVIDER_CLAUDE_IDS = {v.lower() for v in [*_BEDROCK_CLAUDE.values(), *_ANTHROPIC_CLAUDE.values()]}+# Which model answers an agent's own IMAGE questions. hermes asks them separately from the+# conversation (vision_analyze, the browser tools) through its auxiliary router, with a 120 second+# ceiling, and by default against whatever model the harness runs. So choosing a model to write+# with also chose it for looking at pictures, and a harness on a model that is slow or unwilling+# with images spent 120 seconds per audit and got "Request timed out" (a deck task on the demo+# instance, 2026-08-22, qwen3.8-max over an aggregator: twenty minutes of re-render and retry).+#+# A model we list as supported has to work, whichever one it is, with whatever integrations this+# instance has. So vision is resolved like image generation (_image_auth): a capability, served by+# whichever integration can serve it, independent of the turn's chat connection. Every+# integration on the instance is a candidate, in a fixed order so the answer never depends on+# which one was added first; the first that serves a vision-capable model wins, and that+# integration's own credential and endpoint go with it. An instance whose only key is Anthropic+# audits with Claude; one whose only key is OpenAI audits with GPT; one with both uses whichever+# sorts first. When nothing on the instance serves one, hermes keeps its default (the main+# model), which is today's behaviour and the honest answer: we cannot route to a model that no+# integration here can reach.+_VISION_CAPABLE = ("claude-haiku-4.5", "gpt-5.4-mini", "claude-sonnet-5", "gpt-5.6-luna",+ "gpt-5.4", "claude-sonnet-4.6", "claude-opus-5", "gpt-5.5")+++async def _vision_auth(sid: str, backend: str) -> dict | None:+ """Credentials and model for an agent's image questions, or None when no integration on+ this instance serves a vision-capable model. Same shape and trust rules as the chat auth:+ a brokered per-turn credential, never a provider key (self-hosted owner mode is the declared+ exception, where the operator's own key is the point)."""+ if not sid:+ return None+ integrations = sorted(await _integrations_doc(), key=lambda i: str(i.get("name") or ""))+ for integ in integrations:+ served = _integration_models(integ)+ canonical = next((c for c in _VISION_CAPABLE if c in served), None)+ if not canonical:+ continue+ vendor = (integ.get("provider") or "").strip().lower()+ provider = _INTEGRATION_WIRING.get((vendor, backend)) or vendor+ conn = {"name": f"integration:{integ.get('name') or ''}", "backend": backend,+ "provider": provider,+ **{k: v for k, v in (integ.get("config") or {}).items() if v not in (None, "")}}+ auth = _auth_from_conn(conn, sid)+ if not auth or not auth.get("api_key"):+ continue+ return {"provider": provider, "model": served[canonical],+ "base_url": auth.get("base_url") or "", "api_key": auth["api_key"]}+ return None++def _conn_serves(conn: dict, friendly: str) -> bool:"""Whether this connection's vendor actually serves the requested model.@@ -4809,6 +4856,7 @@ async def _resp_execute(translator: _RespTranslator, *, org: str, member: str, scandidates += [(n, None) for n in chain]# Independent of which chat connection wins below: images are usually a different provider.image_auth = await _image_auth(sid, backend)+ vision_auth = await _vision_auth(sid, backend) if backend == "hermes" else Nonefor name, pre in candidates:conn, src = (pre, "integration") if pre is not None else await _get_connection(org, name)if not conn:@@ -4848,6 +4896,10 @@ async def _resp_execute(translator: _RespTranslator, *, org: str, member: str, s"partial_messages": bool(partial_messages),# pi: whether this model's channel takes image input (see _TEXT_ONLY_INPUT)"vision": model_req.strip().lower() not in _TEXT_ONLY_INPUT,+ # hermes: which integration answers its image questions (vision_analyze, browser+ # tools), resolved across the instance like image generation, so the capability+ # does not depend on the model chosen to write with. See _vision_auth.+ "vision_auth": vision_auth,# codex streaming: run via the app-server protocol (item/agentMessage/delta)"codex_appserver": bool(codex_appserver)}# Stop requested while we were resolving the connection / provisioning the previousdiff --git a/gateway/tests/test_vision_auth.py b/gateway/tests/test_vision_auth.pynew file mode 100644index 00000000..2fc7cc09--- /dev/null+++ b/gateway/tests/test_vision_auth.py@@ -0,0 +1,63 @@+"""Vision for hermes is a capability resolved across the instance's integrations, independent of+the writing model, so a supported model is supported whatever it is, with whatever keys exist."""+import asyncio+import os+import sys+from pathlib import Path++sys.path.insert(0, str(Path(__file__).resolve().parents[1]))+os.environ.setdefault("HR_BACKING", "local")+import app # noqa: E402+++def _with(monkeypatch, integrations):+ async def _doc():+ return integrations+ monkeypatch.setattr(app, "_integrations_doc", _doc)+ monkeypatch.setattr(app, "SANDBOX_TRUST", "owner")+++def test_only_anthropic_key_audits_with_claude(monkeypatch):+ _with(monkeypatch, [{"name": "ant", "provider": "anthropic", "config": {"api_key": "ka"}}])+ v = asyncio.run(app._vision_auth("sess1", "hermes"))+ assert v and v["model"].startswith("claude-haiku") and v["api_key"] == "ka"+++def test_only_openai_key_audits_with_gpt(monkeypatch):+ _with(monkeypatch, [{"name": "oai", "provider": "openai", "config": {"api_key": "ko"}}])+ v = asyncio.run(app._vision_auth("sess1", "hermes"))+ assert v and v["model"] == "gpt-5.4-mini" and v["api_key"] == "ko"+++def test_resolution_is_deterministic_by_name_not_insertion_order(monkeypatch):+ integs = [{"name": "zeta", "provider": "openai", "config": {"api_key": "ko"}},+ {"name": "alpha", "provider": "anthropic", "config": {"api_key": "ka"}}]+ _with(monkeypatch, integs)+ a = asyncio.run(app._vision_auth("s", "hermes"))+ _with(monkeypatch, list(reversed(integs)))+ b = asyncio.run(app._vision_auth("s", "hermes"))+ assert a == b and a["api_key"] == "ka"+++def test_no_vision_capable_integration_means_none(monkeypatch):+ # A vendor whose catalogue has no vision-capable model: nothing to route to, so hermes keeps+ # its default rather than being pointed at a model the endpoint cannot serve.+ monkeypatch.setattr(app, "_integration_models", lambda integ: {"llama-3": "llama-3"})+ _with(monkeypatch, [{"name": "local", "provider": "openai-api",+ "config": {"api_key": "k", "base_url": "http://llm.local/v1"}}])+ assert asyncio.run(app._vision_auth("s", "hermes")) is None+++def test_custom_endpoint_with_a_known_catalogue_is_routed(monkeypatch):+ # An OpenAI-compatible endpoint inherits the gpt catalogue, so it can answer image questions+ # with gpt-5.4-mini, through its own base_url.+ _with(monkeypatch, [{"name": "local", "provider": "openai-api",+ "config": {"api_key": "k", "base_url": "http://llm.local/v1"}}])+ v = asyncio.run(app._vision_auth("s", "hermes"))+ assert v == {"provider": "openai-api", "model": "gpt-5.4-mini",+ "base_url": "http://llm.local/v1", "api_key": "k"}+++def test_no_session_means_none(monkeypatch):+ _with(monkeypatch, [{"name": "ant", "provider": "anthropic", "config": {"api_key": "ka"}}])+ assert asyncio.run(app._vision_auth("", "hermes")) is Nonediff --git a/runner/server.py b/runner/server.pyindex 00ae20bf..10a9a1db 100644--- a/runner/server.py+++ b/runner/server.py@@ -1864,7 +1864,8 @@ def _hermes_relay_route(base_url: str, api_key: str) -> tuple[str, str]:def _hermes_prepare_env(provider: str | None, auth: Auth, cwd: str, env: dict,model: str = "", max_turns: int | None = None,- mcp_servers: list[dict] | None = None) -> list[str]:+ mcp_servers: list[dict] | None = None,+ vision_auth: dict | None = None) -> list[str]:"""Point HERMES_HOME inside the checkpointed workspace home (CODEX_HOME precedent) so theconversation state (state.db) survives sandbox recycling, and inject provider creds as env.Writes config.yaml fresh each turn (harness config is the source of truth, like the agent doc).@@ -1889,6 +1890,31 @@ def _hermes_prepare_env(provider: str | None, auth: Auth, cwd: str, env: dict,if max_turns:# hermes 0.19.0 has no --max-turns CLI flag; agent.max_turns in config.yaml is the knob.cfg["agent"] = {"max_turns": int(max_turns)}+ if vision_auth and vision_auth.get("model"):+ # hermes asks its image questions separately from the conversation (vision_analyze, the+ # browser tools) and, left alone, asks the model the harness writes with. That made a+ # capability we list as supported depend on which model the operator picked: one that is+ # slow or unwilling with images returns "Request timed out" after the tool's 120 second+ # ceiling, and the agent re-renders and asks again. The gateway resolved which integration+ # on this instance answers image questions (any integration, not only the turn's) and+ # hands it over whole: provider, model, endpoint, credential. hermes' auxiliary router+ # takes exactly that per task, so only the question about the picture goes elsewhere.+ #+ # The credential takes the same road as the chat one. For an OpenAI-compatible endpoint+ # that is the loopback relay: the CLI sees a placeholder bearer, never the key.+ vp = str(vision_auth.get("provider") or "").lower()+ vision: dict = {"provider": vp, "model": str(vision_auth["model"])}+ vkey, vbase = vision_auth.get("api_key") or "", vision_auth.get("base_url") or ""+ if vp == "openai-api" and vkey and vbase:+ vbase, vkey = _hermes_relay_route(vbase, vkey)+ if vbase:+ vision["base_url"] = vbase+ if vkey:+ # Through the environment, not the file: config.yaml is checkpointed with the+ # workspace and a credential in it would travel in the tarball.+ env["HR_VISION_API_KEY"] = vkey+ vision["key_env"] = "HR_VISION_API_KEY"+ cfg["auxiliary"] = {"vision": vision}# Provider credentials as env — the CLI resolves them at call time.if p == "anthropic":if auth.api_key:@@ -2783,6 +2809,7 @@ class TurnReq(BaseModel):idempotency_key: str = "" # dedup a retried /turn: same key -> same turn, no re-execpartial_messages: bool = False # claude: stream token-level deltas (--include-partial-messages)vision: bool = True # pi: whether the model's channel accepts image input+ vision_auth: dict | None = None # hermes: {provider, model, base_url, api_key} for its image questionscodex_appserver: bool = False # codex: run via app-server (streams item/agentMessage/delta)@@ -2888,7 +2915,8 @@ def turn(req: TurnReq, identifier: str = "") -> dict:model = model or HERMES_DEFAULT_MODELhermes_provider = (req.provider or "bedrock").lower()hermes_mcp = _hermes_prepare_env(hermes_provider, auth, cwd, env, model=model,- max_turns=req.max_turns, mcp_servers=req.mcp_servers)+ max_turns=req.max_turns, mcp_servers=req.mcp_servers,+ vision_auth=req.vision_auth)elif backend == "dsh":model = model or DSH_DEFAULT_MODELcmd = _build_dsh(req.provider, auth, model, req.prompt, cwd, env,diff --git a/runner/tests/test_session_uids.py b/runner/tests/test_session_uids.pyindex b7496799..8ec8fbda 100644--- a/runner/tests/test_session_uids.py+++ b/runner/tests/test_session_uids.py@@ -97,3 +97,34 @@ def test_turn_refuses_a_caller_chosen_cwd_behind_the_wall(monkeypatch, tmp_path)r = c.post("/turn?identifier=sA", json={"prompt": "x", "backend": "claude", "cwd": str(tmp_path)})assert r.status_code == 400assert "identifier" in r.text+++def test_hermes_vision_auth_is_its_own_route(tmp_path, monkeypatch):+ """The model hermes asks about images is the one the gateway resolved, never the writing+ model; the credential rides the loopback relay (OpenAI-compatible) and the environment, and+ is not written into config.yaml (which is checkpointed with the workspace)."""+ import yaml+ env = {"HOME": str(tmp_path)}+ monkeypatch.setattr(server, "_hermes_relay_route",+ lambda base, key: ("http://127.0.0.1:1/v1", "hr-relay-placeholder"))+ server._hermes_prepare_env("openai-api", server.Auth(api_key="k-chat", base_url="https://x/v1"),+ str(tmp_path), env, model="qwen/qwen3.8-max",+ vision_auth={"provider": "openai-api", "model": "gpt-5.4-mini",+ "base_url": "https://vision.example/v1", "api_key": "k-vision"})+ cfg = yaml.safe_load((tmp_path / ".hermes" / "config.yaml").read_text())+ assert cfg["model"]["default"] == "qwen/qwen3.8-max" # writing model untouched+ v = cfg["auxiliary"]["vision"]+ assert v["model"] == "gpt-5.4-mini" and v["provider"] == "openai-api"+ assert v["base_url"] == "http://127.0.0.1:1/v1" # relay, not the endpoint+ assert v["key_env"] == "HR_VISION_API_KEY" and "api_key" not in v+ assert env["HR_VISION_API_KEY"] == "hr-relay-placeholder" # placeholder, never the key+ assert "k-vision" not in (tmp_path / ".hermes" / "config.yaml").read_text()+++def test_hermes_without_vision_auth_keeps_its_default(tmp_path):+ import yaml+ env = {"HOME": str(tmp_path)}+ server._hermes_prepare_env("anthropic", server.Auth(api_key="k"), str(tmp_path), env,+ model="claude-sonnet-5", vision_auth=None)+ cfg = yaml.safe_load((tmp_path / ".hermes" / "config.yaml").read_text())+ assert "auxiliary" not in cfg