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
Every Gemini id is honest through the Gemini CLI, and a substituted turn fails (#111)
github-actions[bot]e1bf3b570e78
diff --git a/docs/support-matrix-notes.md b/docs/support-matrix-notes.mdindex 8b0ee64d..ce465129 100644--- a/docs/support-matrix-notes.md+++ b/docs/support-matrix-notes.md@@ -46,20 +46,25 @@ subset dropped, oneOf to anyOf, const to a one-value enum, exclusive bounds to bto one type plus nullable, a type on every node, items on every array, required limited to existingproperties, an empty declaration dropped). The report is with TokenRouter; when their channelnormalises, this comes out of both trees.-## The gemini backend (Gemini CLI) lists the ids it serves as itself (2026-09-06)+## The gemini backend (Gemini CLI) serves every Gemini id as itself (2026-09-06)gemini-cli speaks Google's native API with the raw key, so the backend runs in owner trust only and-on Google's own ids. Measured on the OSS instance with the org holding only the Google integration,-all five scenarios on each of the eleven ids the google provider serves, 55 of 55 runs passed, artifact-turns included on every Gemini 3.x id (the CLI carries the thought signatures itself). The result-event's stats are keyed by the model the CLI actually called, and that is where the catalog's rule-bites: on the API-key auth path gemini-cli 0.58.0 (and 0.59.0-preview.0 and the 2026-09-06 nightly)-treats "3.5 Flash GA" as launched and its resolver rewrites every id ending in "-flash" to-gemini-3.5-flash, with no setting to turn it off. gemini-3.8-flash, 3.7-flash, 3.6-flash and 2.5-flash-were served by gemini-3.5-flash on every turn and are listed as served-as findings, not passes; the-backend lists the seven ids served as themselves: gemini-3.5-flash, 3.5-flash-lite, 3.1-flash-lite,-3.1-pro-preview, 3-flash-preview, 2.5-pro, 2.5-flash-lite. The four stay reachable on the same key-through the OpenAI-shape harnesses, where Google serves each id as requested on both API surfaces.+on Google's own ids. On the API-key auth path the CLI's resolver rewrites every id ending in "-flash"+to gemini-3.5-flash (0.58.0, 0.59.0-preview.0 and the 2026-09-06 nightly alike), 3.1-pro-preview to+its customtools variant, and its default resolution table retargets 3-flash-preview, 3.5-flash and+2.5-flash by context. The first measurement on the instance (all five scenarios on each of the+eleven ids, org holding only the Google integration, 55 of 55 runs passed, artifact turns included on+every Gemini 3.x id) showed gemini-3.8-flash, 3.7-flash, 3.6-flash and 2.5-flash served by+gemini-3.5-flash on every turn. Richard's rule: the models are honest, no fallback. So the runner+turns on gemini-cli's `experimental.dynamicModelConfiguration`, under which `-m` resolves through the+CLI's resolution table, and writes a `modelConfigs.modelIdResolutions` entry with no contexts for+every id the backend lists and the turn's own model, pinning each to itself (the settings deep-merge+a user entry into the default one, so a plain default alone left 2.5-flash rewritten; the contexts+must be emptied). Measured on the pinned 0.58.0 with those settings, all eleven served as themselves.+And a turn the CLI ran on another model than the one asked for now fails with the reason on the+record ("the CLI ran X instead of Y"), never completes: the matrix's served-model rule, enforced for+the user. The backend lists all eleven; the instance column on 0.14.0 with the served-model rule as+judge is below.## The Gemini family, one provider at a time (2026-09-06)diff --git a/gateway/app.py b/gateway/app.pyindex ed97fd7e..1ccceefe 100644--- a/gateway/app.py+++ b/gateway/app.py@@ -5548,19 +5548,16 @@ _MODEL_CATALOG: dict[str, dict] = {# gemini-3.1-pro (the real Pro flagship) is deliberately NOT listed: Pro was dropped from the# free tier in 2026-04, so it would show as a choice and fail every call on a free-tier key.# Google's own ids only: gemini-cli speaks the native API, so the cross-vendor rows above do not- # apply. Measured 2026-09-06 on the OSS instance (all five scenarios per id, org holding only the- # Google integration, 55 of 55 runs passed) with the served model read off the CLI's own stats:- # on the API-key auth path gemini-cli 0.58.0 treats "3.5 Flash GA" as launched and its resolver- # rewrites every id ending in "-flash" to gemini-3.5-flash (resolveModel with useGemini3_5Flash,- # true for gemini-api-key; the same in 0.59.0-preview.0 and the 0.60 nightly; no setting turns- # it off), so gemini-3.8-flash, 3.7-flash, 3.6-flash and 2.5-flash were served by gemini-3.5-flash- # on every turn and are not listed: a completed turn on them is a turn on 3.5-flash. Those four- # stay reachable on the same key through the OpenAI-shape harnesses, where Google serves each id- # as requested. The seven below were served as themselves on every turn.+ # apply. The ids are honest: the runner turns on gemini-cli's dynamic model configuration and+ # pins every id here to itself, since on the API-key auth path the CLI's resolver otherwise+ # rewrites every id ending in "-flash" to gemini-3.5-flash (0.58.0, measured 2026-09-06), and a+ # turn the CLI ran on another model than the one asked for fails with the reason on the record,+ # never completes. Measured 2026-09-06 on the pinned 0.58.0 with those settings: all eleven+ # served as themselves; the instance column with the served-model rule as judge is in the notes."gemini": {"default": "gemini-3.5-flash",- "models": ["gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.1-flash-lite",- "gemini-3.1-pro-preview", "gemini-3-flash-preview", "gemini-2.5-pro",- "gemini-2.5-flash-lite"]},+ "models": ["gemini-3.5-flash", "gemini-3.8-flash", "gemini-3.7-flash", "gemini-3.6-flash",+ "gemini-3.5-flash-lite", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview",+ "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite"]},}_BARE_MODELS = {"", "claude", "codex", "anthropic", "bedrock", "openai", "hermes", "pi", "dsh", "deepseek"}# Models whose serving CHANNEL refuses image input outright. Measured, not assumed — probeddiff --git a/runner/server.py b/runner/server.pyindex f7b39438..ace078b0 100644--- a/runner/server.py+++ b/runner/server.py@@ -2957,9 +2957,20 @@ def _build_qwen(provider: str, auth: Auth, model: str, prompt: str, cwd: str, en# of this set until the gateway side decides how (or whether) to broker it; see the gateway's# _BROKERABLE_PROVIDERS comment for bedrock/vertex.GEMINI_PROVIDERS = {"google"}---def _gemini_settings(home: pathlib.Path, mcp_servers: list[dict] | None) -> None:+# Every Gemini id the gateway's gemini catalog lists. gemini-cli's resolver rewrites ids on the+# API-key auth path (every "-flash" id to gemini-3.5-flash, 3.1-pro-preview to its customtools+# variant, and by context in its default resolution table); with dynamicModelConfiguration on, -m+# goes through the resolution table instead, and an entry with no contexts pins an id to itself.+# The settings deep-merge a user entry into the default one, so the contexts must be emptied+# explicitly (a plain default alone left gemini-2.5-flash rewritten, measured 2026-09-06 on 0.58.0).+# Every listed id is pinned, and the turn's own model with it, so no context can retarget any of+# them; a served model that still differs fails the turn (see _gemini_to_claude).+GEMINI_MODELS = ("gemini-3.8-flash", "gemini-3.7-flash", "gemini-3.6-flash", "gemini-3.5-flash",+ "gemini-3.5-flash-lite", "gemini-3.1-flash-lite", "gemini-3.1-pro-preview",+ "gemini-3-flash-preview", "gemini-2.5-pro", "gemini-2.5-flash", "gemini-2.5-flash-lite")+++def _gemini_settings(home: pathlib.Path, mcp_servers: list[dict] | None, model: str = "") -> None:"""~/.gemini/settings.json under the redirected HOME.mcpServers uses gemini-cli's own schema (command/args/env for stdio, url/httpUrl/headers for@@ -2995,7 +3006,11 @@ def _gemini_settings(home: pathlib.Path, mcp_servers: list[dict] | None) -> Noneelse:continueservers[name] = entry- cfg: dict = {"security": {"auth": {"selectedType": "gemini-api-key"}}}+ pinned = sorted(set(GEMINI_MODELS) | ({model} if model else set()))+ cfg: dict = {"security": {"auth": {"selectedType": "gemini-api-key"}},+ # the ids are honest: -m resolves through this table, and each entry pins an id to itself+ "experimental": {"dynamicModelConfiguration": True},+ "modelConfigs": {"modelIdResolutions": {m: {"default": m, "contexts": []} for m in pinned}}}if servers:cfg["mcpServers"] = servers(gdir / "settings.json").write_text(json.dumps(cfg, indent=2))@@ -3012,7 +3027,7 @@ def _build_gemini(provider: str, auth: Auth, model: str, prompt: str, cwd: str,home.mkdir(parents=True, exist_ok=True)env["HOME"] = str(home) # sessions/skills/settings live INSIDE the workspaceenv["GEMINI_API_KEY"] = auth.api_key- _gemini_settings(home, mcp_servers)+ _gemini_settings(home, mcp_servers, model)cmd = ["gemini", "-p", prompt, "-o", "stream-json", "-m", model,# Load-bearing, same risk class as qwen's --yolo: gemini-cli gates tool use behind a# per-workspace "folder trust" prompt and an approval mode, neither of which can be@@ -3625,6 +3640,14 @@ def _gemini_to_claude(obj: dict, state: dict) -> list[dict]:# the result so the gateway can record a substitution instead of believing the request.models = stats.get("models") if isinstance(stats.get("models"), dict) else {}served = ",".join(k for k in models if isinstance(k, str) and k)+ # A substitution is a failed turn, not a served one: the model the CLI ran is what the user+ # gets, and a turn that ran another model than the one asked for must say so, never read+ # completed. The settings pin every id to itself; this is the check that they held.+ requested = str(state.get("model") or "")+ other = [m for m in served.split(",") if m and requested and m != requested]+ if other and not err:+ err = {"type": "model_substituted", "message": f"the CLI ran {', '.join(other)} instead of {requested}"}+ msg = err["message"]ev = {"type": "result", "subtype": "error" if err else "success", "is_error": bool(err),"result": msg or state.get("final", ""), "usage": _gemini_usage(stats)}if served:diff --git a/runner/tests/test_gemini_build.py b/runner/tests/test_gemini_build.pyindex df7913fe..22cf69b6 100644--- a/runner/tests/test_gemini_build.py+++ b/runner/tests/test_gemini_build.py@@ -9,7 +9,7 @@ import tempfilesys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))from server import (Auth, _agent_doc_path, _build_gemini, _gemini_to_claude, # noqa: E402- _gemini_usage, _norm_token_usage, BACKENDS)+ _gemini_usage, _norm_token_usage, BACKENDS, GEMINI_MODELS)def _argv(**kw):@@ -197,3 +197,34 @@ def test_the_result_carries_the_served_model_and_the_fresh_input_beside_the_cach"model": "gemini-3.5-flash"}]assert _gemini_usage({}) == _norm_token_usage({}) # the same shape as every other normalizerassert _gemini_usage({"input_tokens": 100, "output_tokens": 5})["input_tokens"] == 100+++def test_every_listed_id_and_the_turns_model_are_pinned_to_themselves():+ """gemini-cli rewrites ids on the API-key auth path (every "-flash" id to gemini-3.5-flash, measured+ 2026-09-06 on 0.58.0); with dynamicModelConfiguration on and an entry with NO contexts per id, each+ is served as itself (all eleven measured). The contexts must be emptied explicitly: the settings+ deep-merge a user entry into the default one."""+ d = tempfile.mkdtemp()+ env: dict = {}+ _build_gemini("google", Auth(api_key="k"), "gemini-3.8-flash", "hi", d, env)+ cfg = json.loads(pathlib.Path(d, ".harness", "home", ".gemini", "settings.json").read_text())+ assert cfg["experimental"] == {"dynamicModelConfiguration": True}+ res = cfg["modelConfigs"]["modelIdResolutions"]+ for m in GEMINI_MODELS:+ assert res[m] == {"default": m, "contexts": []}+ d2 = tempfile.mkdtemp()+ _build_gemini("google", Auth(api_key="k"), "gemini-9-flash", "hi", d2, {})+ res2 = json.loads(pathlib.Path(d2, ".harness", "home", ".gemini", "settings.json").read_text())["modelConfigs"]["modelIdResolutions"]+ assert res2["gemini-9-flash"] == {"default": "gemini-9-flash", "contexts": []} # the turn's own model too+++def test_a_served_model_other_than_the_one_asked_for_fails_the_turn():+ """Richard's rule: the models are honest, no fallback. A substitution is a failed turn with the+ reason on the record, never a completed one."""+ stats = {"input_tokens": 10, "output_tokens": 2, "cached": 0, "models": {"gemini-3.5-flash": {}}}+ out = _gemini_to_claude({"type": "result", "status": "success", "stats": stats}, {"model": "gemini-3.8-flash", "final": "PONG"})+ assert out[0]["is_error"] is True and out[0]["subtype"] == "error"+ assert out[0]["result"] == "the CLI ran gemini-3.5-flash instead of gemini-3.8-flash"+ assert out[0]["model"] == "gemini-3.5-flash"+ ok = _gemini_to_claude({"type": "result", "status": "success", "stats": {**stats, "models": {"gemini-3.8-flash": {}}}}, {"model": "gemini-3.8-flash", "final": "PONG"})+ assert ok[0]["is_error"] is False and ok[0]["result"] == "PONG"diff --git a/ui/src/lib/harness.ts b/ui/src/lib/harness.tsindex bad557a0..b4828ab8 100644--- a/ui/src/lib/harness.ts+++ b/ui/src/lib/harness.ts@@ -92,9 +92,9 @@ export const OOB: OobHarness[] = [// reach into the gpt/claude/deepseek/etc catalogs the way qwen/pi/opencode do, because it// speaks neither the OpenAI nor the Anthropic wire protocol. Placeholder until the gateway's// /v1/models catalog for this backend is populated (see gateway's _MODEL_CATALOG["gemini"]).- // the seven ids gemini-cli 0.58.0 serves as themselves on the API-key path (it rewrites every id ending in- // "-flash" to gemini-3.5-flash); measured 2026-09-06, all five scenarios per id through this backend- models: ['gemini-3.5-flash', 'gemini-3.5-flash-lite', 'gemini-3.1-flash-lite', 'gemini-3.1-pro-preview', 'gemini-3-flash-preview', 'gemini-2.5-pro', 'gemini-2.5-flash-lite'], defaultModel: 'gemini-3.5-flash', moreModels: 0,+ // Google's own ids, each served as itself: the runner pins every id in gemini-cli's resolution table (the CLI+ // otherwise rewrites every "-flash" id to gemini-3.5-flash), and a substituted turn fails rather than completes+ models: ['gemini-3.5-flash', 'gemini-3.8-flash', 'gemini-3.7-flash', 'gemini-3.6-flash', 'gemini-3.5-flash-lite', 'gemini-3.1-flash-lite', 'gemini-3.1-pro-preview', 'gemini-3-flash-preview', 'gemini-2.5-pro', 'gemini-2.5-flash', 'gemini-2.5-flash-lite'], defaultModel: 'gemini-3.5-flash', moreModels: 0,systemPrompt: 'You are Gemini CLI, an autonomous coding agent. You work on a real git workspace with shell and file access, reading and editing files and running commands to complete the task end to end.',tools: [], skills: [] },{ id: 'cline', name: 'Cline', version: 'v3.0.60', backend: 'cline', status: 'ready',